This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question related to Tomcat /JSP

 
Saket Barve
Ranch Hand
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Saket Barve
Ranch Hand
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 229
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic