A Process to run a servlet hello program

  1. Create a application(user-defined) folder inside the webapp folder of tomcat.                           let it be MyProject.
  2. Create a WEB-INF folder inside your application folder(inside MyProject folder). 
  3. Create classes folder inside WEB-INF folder.
  4. Create a  servlet program with .java extension like HelloServlet.java.
  5. Copy the path C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar  where c: drive tells that tomcat is installed in c derive and 7.0 is version of tomcat i.e it is the path of servlet-api.jar file which is atomatically created  in lib folder after installing tomcat.Because the set of classes required for writing servlets is available in a jar file called servlet-api.jar
  6. Paste above copied path  under My computer->properties->Advanced->Environmental variable->System variable->classpath->Edit-> paste under variable value. 
  7. Copy the path C:\Program Files\Java\jdk1.6.0\bin; and paste it under My computer->properties->Advanced->Environmental variable->System variable->path->Edit-> paste under variable value. It tells that it is the path where the  java copiler is created after installing jdk(java development kit). 
  8. Now copile the created  HelloServlet.java file with the help of Command prompt as  file path then javac HelloServlet.java. A class file is created now where HelloServlet.java file compiled.
  9. Copy the class file of  HelloServlet.java program file. 
  10.  Paste it inside the classes folder of Step 3. 
  11. Create a web.xml file with servlet name,URL and servlet mapping,URL of above HelloServlet.java program inside the WEB-INF folder of step 2.
  12. Run tomcat with path Start-> Control Panel-> Performance and Maintenance-> Administrative Tools -> Services-> Apache Software Foundation OR C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin and double click on tomcat(service runner) OR Start->Programs->Apache Tomcat 6.0 -> Monitor Tomcat. You will notice an icon appear on the right side of your Status Bar.   Right click on this icon and click on Start service.
  13. open  Browser and type URL as localhost:8080/ MyProject/ url specified in web.xml file. MyProject is application folder name created in step 1.
  14. .As you will enter this URL,You will see that your HelloServet.java on Browser.



Counters