JSP using "MyClass

D

Doug Schaible

I have been trying to get a JSP to "talk" with a class that I wrote.
I wrote a class called Wlm to call a stored procedure in a database.
I then added Wlm(parms...) to my JSP and I get an error:
/tmp/jsp_servlet/_wlm/__call_sp_start_stop.java:349: cannot resolve
symbol
symbol : method Wlm
(java.lang.String,java.sql.Connection,java.lang.String,java.lang.String)
location: class jsp_servlet._wlm.__call_sp_start_stop
Wlm(databaseURL, db2, command, results);

This is all the code in my JSP that call Wlm:
Wlm(databaseURL, db2, command, results);

This is the Wlm class which compiles fine:
import java.sql.* ;
import java.util.* ;
import com.ibm.* ;
public class Wlm{

public Wlm( String databaseURL, java.sql.Connection db2, String
command, String results)
{
try{
java.sql.Statement st2;
java.sql.ResultSet rs2;
int one2 = 1;
try{
Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch( ClassNotFoundException e ){
//
}
db2.close();
java.util.Properties properties = new java.util.Properties ();
properties.setProperty ("user", "xxxx");
properties.setProperty ("password", "xxxx");
db2 = java.sql.DriverManager.getConnection (databaseURL,
properties);
//((com.ibm.db2.jcc.DB2Connection)db2).setDB2ClientApplicationInformation("WLM_QUERY_WEB");


// set the path to our schema name so we can find our procedure
st2 = db2.createStatement();
st2.execute("SET CURRENT FUNCTION PATH DB2SYS");

CallableStatement stmtSP = db2.prepareCall("CALL
DB2SYS.DB2_COMMAND(?)");
stmtSP.setString(1, command.toUpperCase());
stmtSP.execute();

results = "";

rs2 = stmtSP.getResultSet();
while (rs2.next())
{
results = results + "<br>" + rs2.getString(one2);

}
}
catch (SQLException e)
{
//out.println("error");
}
}
}


Thanks in advance for any help,

Doug
 
W

Wendy S

Doug Schaible said:
This is the Wlm class which compiles fine:
import java.sql.* ;
import java.util.* ;
import com.ibm.* ;
public class Wlm{

Did you import the class into your JSP? Is your class in a named package?
 
K

kaeli

I have been trying to get a JSP to "talk" with a class that I wrote.

I had to put mine in a package and import it to get it to work.
The path to the package had to be added to the JVM classpath in the
webserver, too.

Just a thought.

--
 
L

Luke Matthews

Perhaps I'm way off base, but couldn't you throw the imports in the
"<%@ page import" part at the start of your jsp page and declare the
class inside a "<%!" tag section? I made a time conversion method a
while back (to display milliseconds, seconds, etc, based on how many
milliseconds elapsed between a start and end time) and it worked nice
inside the <%! tag.

--Luke
 
S

Scott Yanoff

Doug said:
I have been trying to get a JSP to "talk" with a class that I wrote.
I wrote a class called Wlm to call a stored procedure in a database.
I then added Wlm(parms...) to my JSP and I get an error:
/tmp/jsp_servlet/_wlm/__call_sp_start_stop.java:349: cannot resolve
symbol
symbol : method Wlm

Can you please post some of the relevant JSP code? We can help you
debug from there.

Also, where does the class reside? Are you doing an "import" statement
in your JSP so that it can find it? Is it in a jar file that is in your
server's classpath? Lastly, is the class really a java bean, which is
what you typically call from a JSP?

Good luck,
-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top