File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Question related to Tomcat /JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question related to Tomcat /JSP" Watch "Question related to Tomcat /JSP" New topic

Question related to Tomcat /JSP

Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
I have a JSP file, called testConnection.jsp which uses a to connect to JDBC database. Work is being done in UNIX platform.
The 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.
Sam Dalton
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)
myjsp.jsp <- all JSPs go at this level
/WEB-INF <- case sensitive
web.xml <- if appropriate
/mypackage <- ta in your case

More information can easily be found here
Hope this helps

<a href="" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of []Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
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.
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*;"
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
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 file everytime I make a relevant change.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
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.
I agree. Here's the link:
subject: Question related to Tomcat /JSP
It's not a secret anymore!