You have a classpath setup issue, and the next point is you can save the file any where, only the generated class file should be in proper place.
I assume you have a setup of windows xp might be same in vista not very sure with tomcat server.
Step1: set the classpath
My Computer->properties->Advanced->Environment variable
Now under user variable if there is any variable called classpath, click edit at end of the variable value put a ; paste the path of servlet-api.jar which is under lib of tomcat home for e.g.
If dont have any classpath variable , create new , variable name classpath value as follows
%classpath%;C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\lib\servlet-api.jar;.
Apply the settings
The mentioned path and version mentioned above may change based on your installation
Compile your code.
Create the directory structure under tomcat. under webapps folder of tomcat home create a folder(i.e. you context root folder which will contain your web pages , servlets etc.). Under this folder create another folder called WEB-INF and under WEB-INF create another folder called classes.
Now copy your generated package or class file , whatever you have to this classes folder, and put the web.xml file under WEB-INF folder.
under webapps create a folder called publications. under this folder create a folder called WEB-INF and copy your web.xml file here. Now under WEB-INF folder create a folder called classes and copy your package i.e test to this classes folder. Now restart tomcat and type the following url in browser
Yes I did what you suggested and I have now deleted web.xml in C:\Tomcat5027\webapps\ROOT\WEB-INF
so I'm left with web.xml in C:\Tomcat5027\conf
but my HelloWorld.class & HelloWorld.java is in C:\Tomcat5027\webapps\ROOT\WEB-INF\classes\test
You are probably not getting me properly are probably I am not being able to explain you properly. In tomcat rather in any web application we need to to maintain a particular directory structure. As far as tomcat is concerned we need to follow the following directory structure. Forget about that ROOT folder. The publication folder which you are saying contains your web site contents should be under webapps not under ROOT. now the publication folder should contain WEB-INF which will contain the web.xml file(web deployment desciptor). Under the same folder i.e. WEB-INF you need another folder called classes which will contain your package/or class files. So in your case test is the package which contains the servlet class file.
After making the changes please do restart your server.
Nina Savannah wrote:I'm trying to get this servlet to work but i'm getting errors.
Here is what I did:-
I added the following code to web.xml to invoke my servlet in C:\Tomcat5027\conf
Once you get your servlet to compile,
You should create a deployment descriptor specifically for your application and place it under your application's WEB-INF directory.
The global deployment descriptor (the one in tomcat/conf/) is for configuring behavior common to all applications running under Tomcat.