
First I installed the tomcat server in C:\apache-tomcat-6.0.14 directory.
Then I created a system variable CATALINA_HOME with the value C:\apache-tomcat-6.0.14.
Then I created another system variable JAVA_HOME with the value C:\Program Files\Java\jdk1.6.0.14
Then I created another environment variable CLASSPATH with the value C:\apache-tomcat-6.0.14\lib\servlet-api.jar
Then I created my servlet file Servlet_LifeCycle.java under the folder C:\apache-tomcat-6.0.14\webapps\demo-examples. The demo-examples folder was created by me.
To compile my servlet program I did the following:
C:\apache-tomcat-6.0.14\webapps\demo-examples>javac Servlet_LifeCycle.java
But the compilation failed totally.

Hi Friend,
Follow these steps:
1)create a servlet.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}
2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.
3)Create web.xml and classes folder inside the WEB_INF folder of web application folder assuming examples.
4)Copy the servlet to the classes folder.
5)Edit the web.xml to include servlet?s name and url pattern.
<servlet> <servlet-name>Hello</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloWorld</url-pattern> </servlet-mapping>
6)Compile your servlet.
7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.
8)Open the browser and type the following url:
http://localhost:8080/webapplicationfoldername/servletname
For more information, visit the following link:
http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml
Thanks

Hi Friend,
Follow these steps:
1)create a servlet.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}
2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.
3)Create web.xml and classes folder inside the WEB_INF folder of web application folder assuming examples.
4)Copy the servlet to the classes folder.
5)Edit the web.xml to include servlet?s name and url pattern.
<servlet> <servlet-name>Hello</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloWorld</url-pattern> </servlet-mapping>
6)Compile your servlet.
7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.
8)Open the browser and type the following url:
http://localhost:8080/webapplicationfoldername/servletname
For more information, visit the following link:
http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.