File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Java 8 in Action this week in the Java 8 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: 12682
    
    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


Java Resources at www.wbrogden.com
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet not working
 
Similar Threads
Class Not Found exception in JSP using SQL 2K
Tomcat exception
Class cast exception
[solved]Struts 2 and Vaadin
about database connectivity