java4all@1986 java. Powered by Blogger.

How to run a servlet?

>> Tuesday, June 7, 2011

To run a servlet one should follow the steps illustrated below:

   1.) Download and Install the tomcat server: Install the tomcat server in a directory in which you want to install and set the classpath.for the variable JAVA_HOME in the environment variable. To get details about the installation process and setting the classpath click the link Tomcat installation.

   2.) Set the class for the jar file: Set the classpath of the servlet-api.jar file in the variable CLASSPATH inside the environment variable by using the following steps.

    For Windows XP,

   3.) Go to Start->Control Panel->System->Advanced->Environment Variables->New button and Set the values as
    Variable Name:  CLASSPATH
    Variable Value:  C:\Program Files\Java\Tomcat 6.0\lib\servlet-api.jar

    For Windows 2000 and NT

   4.) Go to Start->Settings->Control Panel->System->Environment Variables->New button and Set the values as
    Variable Name:  CLASSPATH
    Variable Value:  C:\Program Files\Java\Tomcat 6.0\lib\servlet-api.jar

    Create a java source file and a web.xml file in a directory structure.

    Compile the java source file, put the compiled file (.class file) in the classes folder of your application and deploy the directory of your application in the webapps folder inside the tomcat directory.

    Start the tomcat server, open a browser window and type the URL http://localhost:8080/directory (folder name of your application) name/servler name and press enter.

    If everything is correct your servlet will run.

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP