How to Deploy servlet using Tomcat 5

Hi All,
I m practically new to Servlets.I have written a servlet and i want to deploy it.I m using Tomcat 5 , Jdk 1.5 on windows vista, can any one tell me how to set the classpath and all to compile my servlet.

There's more to running a servlet than just compiling a single class. Web applications have a fairly complex structure, defined by the WAR architecture specification. So the first thing you need to to is build a WAR. You'd normally want to use some sort of tools to do this, such as Ant or Maven. Some people let their IDEs do all the work, although that's a very poor alternative.

Once you've built a WAR, you need to deploy it. The Tomcat website has very good documentation on WARS and their configuration and deployment. Tomcat itself supports both standards-compliant WAR files and so-called "exploded" WARS, which are whay you'd get if you unzipped a WAR file. There's a "webapps" directory where Tomcat normally expects to put these things, although Tomcat can also find WARs and exploded WARs in other places when configured to do so.

If this sounds like a way to politely say RTFM, well, it is. There's more to the process than we can take the time or space to explain here, so the best we can do is help you find good materials for study. The Tomcat docs at http://tomcat/apache.org are pretty good, but you'd probably want to find some good books on J2EE/JEE and find some local people who know it already and are willing yo help out. Bribery is always useful.

Customer surveys are for companies who didn't pay proper attention to begin with.

To start from the beginning ...to set the classpath go to the directory where you have deployed tomcat/lib/common/ and copy the address to the environment variable CLASSPATH

then compile your .java file where you have and copy the .class file to the tomcat/webapp/(your directory if any)/WEB-INF/classes
then you include your servlet in WEB-INF/web.xml
open a browser and http://localhost:8080/(your directory if any)/Servlet name

It seems that classpath is not set correctly, it is better to use any IDE like Eclipse.

Thanks,
Deepak.

AsifAimen Iqbal
Greenhorn

Joined: Mar 06, 2009
Posts: 9

posted Mar 07, 2009 00:51:24

0

Thanks Deepak,
But I want to start with the Basic and i m stuck here dont know what to do.I did set CLASSPATH and path correctly but i have placed my servlet in package is that the reason for the error!!!