- Create a application(user-defined) folder inside the webapp folder of tomcat. let it be MyProject.
- Create a WEB-INF folder inside your application folder(inside MyProject folder).
- Create classes folder inside WEB-INF folder.
- Create a servlet program with .java extension like HelloServlet.java.
- 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
- Paste above copied path under My computer->properties->Advanced->Environmental variable->System variable->classpath->Edit-> paste under variable value.
- 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).
- 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.
- Copy the class file of HelloServlet.java program file.
- Paste it inside the classes folder of Step 3.
- 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.
- 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.
- open Browser and type URL as localhost:8080/ MyProject/ url specified in web.xml file. MyProject is application folder name created in step 1.
- .As you will enter this URL,You will see that your HelloServet.java on Browser.
Sunday, 29 January 2012
A Process to run a servlet hello program
Subscribe to:
Post Comments (Atom)




No comments:
Post a Comment