This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Servlets and the fly likes servlet not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet not working" Watch "servlet not working" New topic
Author

servlet not working

phani bhushan reddy
Greenhorn

Joined: Jul 20, 2007
Posts: 27

When i was try to connect to database doing servlets, it was throwing an exception called ClassNotFoundException, but i actually know the meaning of this but the jdbc connectivity is working the general and swing programs, but it was throwing an exception while using servlets, please tell me the solution, I am using Tomcat5.5
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Tomcat does NOT use your system environment variables such as classpath to locate a database. You must configure Tomcat with specific database information. I am sure this is all covered in the tomcat-doc section of a typical Tomcat installation.

Bill
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
As William said , the classpaht is ignored by Tomcat. So where are you putting the driver classes jar.In case of web applications it should be within WEB-INF/lib folder.


Rahul Bhattacharjee
LinkedIn - Blog
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Rahul Bhattacharjee:
As William said , the classpaht is ignored by Tomcat. So where are you putting the driver classes jar.In case of web applications it should be within WEB-INF/lib folder.


This assumes that the original poster is using forName to find the driver which is probably a good assumption since he mentioned that the same code works in a Swing app.

A better approach for getting connection for a web application is to use container managed connection pooling.
See:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
to learn how to set this up for the container you're using.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
Don't get me started about those stupid light bulbs.
 
subject: servlet not working