| Author |
Question related to Tomcat /JSP
|
Saket Barve
Ranch Hand
Joined: Dec 19, 2002
Posts: 224
|
|
I have a JSP file, called testConnection.jsp which uses a ConnectionBean.java to connect to JDBC database. Work is being done in UNIX platform. The ConnectionBean.java is working fine when tested with a main method - it accesses and retrieves the data. Also, I am able to view a ordinary JSP page on the browser. I have made appropriate changes to the server.xml file in tomcat installation. I get an error saying that the package ta does not exist. Even if I remove the package name from the files, the error persists, now the error being class ConnectionBean symbol cannot be resolved. Is the error is related to setting the CLASSPATH (UNIX platform)? I have copied my friend's CLASSPATH from his .cshrc (which he'd used successfully for his own code, to access the same database). That didn't solve the problem. I'd appreciate any feedback at the earliest. Thanks, Saket
|
 |
Sam Dalton
Author
Ranch Hand
Joined: Jul 26, 2001
Posts: 170
|
|
HI there. In order to make this work, you will need to package your JSP and classfiles up into a web application. A Simple structure chould look like: (this is within the Tomcat/webapps directory) /mywebapp myjsp.jsp <- all JSPs go at this level /WEB-INF <- case sensitive web.xml <- if appropriate /classes /mypackage <- ta in your case /myclass.class More information can easily be found here Hope this helps Sam
|
<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
|
 |
Saket Barve
Ranch Hand
Joined: Dec 19, 2002
Posts: 224
|
|
Thanks for the reply Sam. My directory structure is indeed just as you have described in your message. The problem persists. I seem to be missing out on something trivial, yet not quite! If anyone has ideas/suggestions, please do let me know. Thanks, Saket
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
Did you import the bean class in the JSP page? There is a special JSP tag that will import external classes, much like in a regular java class you need to "import java.net.*;"
|
 |
Saket Barve
Ranch Hand
Joined: Dec 19, 2002
Posts: 224
|
|
Thanks for the suggestion Mike. I realized that after making changes to the .java file, I wasn't compiling them to get the latest (and appropriate) .class files for the .jsp page to work on. Being new to JSP, I wasn't not aware of the need to compile the XXXXBean.java file everytime I make a relevant change. Saket
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
Something that frequently trips people up: in your jsp:useBean tag you MUST give the complete package with the class name in addition to importing the class with an import statement as Mike says. Bill
|
 |
 |
|
|
subject: Question related to Tomcat /JSP
|
|
|