Java Tutorial - Java Script : Using Servlets

Java Tutorial - Java Script :

Using Servlets

Another way to get these files is to use the Java servlet class library that ships with the server you’ll be using to deploy these applications. Running servlets and JSP requires a server that supports the technologies. Servlets are supported by several web servers, each of which has its own installation, security, and administration procedures. The most popular choice for new servlet developers is Tomcat, an open source server developed by the Apache Software Foundation in cooperation with Sun Microsystems. Version 5.5 of Tomcat supports Java Servlet 2.4 and JSP 2.0. Tomcat can run in conjunction with another web server (such as Apache’s web server) or as a standalone server. Your current web server or web application server might already include support for servlets. The software is available as a free download from Apache’s website at the address http://jakarta.apache.org/tomcat. Several versions are available: Download version 5.5. Full installation instructions for Tomcat are available from the website. If you want to run it as a standalone server for testing purposes, in most cases, the following procedure worksView the downloads page for Tomcat and other Apache projects: Visit http://jakarta.apache.org/tomcat, and in the Downloads section of the site menu, click the Binaries link. A page opens with links to Apache software you can download, which are called builds.In the Release Builds section, scroll to the Tomcat 5.5 heading. The software can be downloaded as a ZIP archive, an archive compressed with TAR and GZ, or a Windows installer.
·         Click the link of the version you want to download.
·         Install the software, making note of the folder where it is installed.
·         Create an environmental variable called JAVA_HOME that contains the folder where Java is installed on your computer.
·         Create an environmental variable called CATALINA_HOME that contains the folder where Tomcat was installed.
In the bin folder of the Tomcat installation, use either catalina.sh or catalina.bat to run the server with one of these commands:
catalina.sh start
catalina.bat start
Tomcat begins running at port 8080 of your computer. (There’s also a stop command to shut it down.)To verify that it’s running, open the address http://localhost:8080 with a web browser. If you’re testing Tomcat from another computer, replace localhost with the domain name or IP address of the server where Tomcat has been installed.
Add to your Classpath a reference to the Java servlet class library, servletapi. jar, that ships with Tomcat. In version 5.5, it’s in the common\lib subfolder.
 If you don’t have a server but you want to begin developing servlets, several companies offer commercial web hosting with Java servlet support. These companies have already installed Tomcat and configured it to work with their servers, leaving you to focus on writing servlets using the classes of the javax.servlet and javax.servlet.http packages