The Tomcat JSPServlet Container

 < Day Day Up > 



The Tomcat JSP/Servlet Container

The Tomcat JSP/Servlet container is an open-source Java-based Web application container created to run servlet and JavaServer Page Web applications. It has become Sun's reference implementation for both the Servlet and JSP specifications. We use Tomcat for all of our examples in this book.

Before we get started with the installation and configuration of Tomcat, you need to make sure you have acquired the items listed in Table 1.3.

Table 1.3: Tomcat Installation Requirements

Component

Location

Jakarta-Tomcat 4.1.24 LE

http://jakarta.apache.org/

JDK 1.4.1 Standard Edition

http://java.sun.com/j2se/1.4/

Installing and Configuring Tomcat

Once you have Tomcat and the JDK downloaded, go ahead and install them according to their packaged instructions. For our purposes, we are installing Tomcat as a stand-alone server on a Windows XP operating system (OS). We are installing Tomcat in the directory C:\Tomcat 4.1 and the JDK in the directory C:\j2sdk1.4.1_02.

After we have Tomcat and the JDK installed, the next step is to set the JAVA_HOME environment variable. This variable is used to compile your requested JSPs. To do this under XP, perform these steps:

  1. Open the Windows XP Control Panel.

  2. Start the System Application, and then select the Advanced tab.

  3. Click the Environment Variables button. You will see a screen similar to Figure 1.3.

    click to expand
    Figure 1.3: The Windows NT/2000 Environment Variables dialog box.

  4. Click the New button in the System Variables section of the Environment Variables dialog box. Add a Variable named JAVA_HOME and set its value to the location of your JDK installation. Figure 1.4 shows the settings associated with our installation.

    click to expand
    Figure 1.4: The JAVA_HOME environment settings for our installation.

That's all there is to it. You can now move on to the next section, in which we test the Tomcat installation.

Testing Your Tomcat Installation

Before continuing, let's test the steps we have just completed. To begin, first start the Tomcat server by typing the following command (be sure to replace <CATALINA_HOME> with the location of your Tomcat installation):

 <CATALINA_HOME>\bin\startup.bat 

Once Tomcat has started, open your browser to the following URL:

  • http://localhost:8080

You should see the default Tomcat home page, which is displayed in Figure 1.5.

click to expand
Figure 1.5: The default Tomcat home page.

The next step is to verify the installation of our JDK. The best way to do this is to execute one of the JSP examples provided with the Tomcat server. To execute a sample JSP, start from the default Tomcat home page, shown in Figure 1.5, and choose JSP Examples. You should see a page similar to Figure 1.6.

click to expand
Figure 1.6: The JSP Examples page.

Now choose the JSP example Snoop and click the Execute link. If everything was installed properly, you should see a page similar to the one shown in Figure 1.7.

click to expand
Figure 1.7: The results of executing the Snoop JSP example.

If you do not see the page shown in Figure 1.7, make sure that the location of your JAVA_HOME environment variable matches the location of your JDK installation.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net