• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question related to Tomcat /JSP

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic