None of the forum threads, e-book, blog posts etc.. helped me directly in solving this issue. I spent a whole Saturday figuring it out. Maybe I wasn't very attentive.. anyway,here is the solution:
1. In the webapps directory under the tomcat6 create a new directory HelloWorld
2. Next create the following directories:
..\webapps\HelloWorld\WEB-INF
..\webapps\HelloWorld\WEB-INF\classes
3. in the WEB-INF directory you need to put a XML configuration file with the following content:
HelloWorld
HelloWorld
HelloWorld
/HelloWorld
welcome.html
4. In the classes directory you put your .java file with the servlet code. I used the following:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("Hello World! ");
out.println("");
out.println("");
out.println("Hello World!
");
out.println("");
out.println("");
}
}
5. Next you need to indicate the place where the library servlet-api.jar resides. In order to do that you need to set the CLASSPATH variable to the full path of this jar file.
>SET CLASSPATH=C:\apache-tomcat-6.0.20\lib\servlet-api.jar
6. Now you need to compile you .java file. For this you need to run the following commands. First change the current directory to classes folder. Then run the java compiler.
>cd ..webapps\HelloWorld\WEB-INF\classes
>javac HelloWorld.java
7. Now you are all done. you can run the applet from the browser typing the following address: http://localhost:8080/HelloWorld/HelloWorld.
Voila !



