Recipe 11.1 Installing Tomcat

     

11.1.1 Problem

You need access to a JSP and servlet web container.

11.1.2 Solution

Download and install the Tomcat web server, which is the reference installation for JSP and servlets. You can get Tomcat at http://jakarta.apache.org/tomcat/ for free. Installation is easy; just download the compressed file for your operating system and uncompress it. Tomcat is a Java application, so no special installation is needed.

11.1.3 Discussion

If you don't have access to a JSP/servlet web server, download Tomcat from http://jakarta.apache.org/tomcat/; just select the compressed file for your operating system. One of the good things about Tomcat is that all you have to do to install it is to unzip/ untar it. Tomcat is a Java application, so it'll run using your Java installation (see Recipe Recipe 11.2 for more information).

We'll use the most recent version of Tomcat as of this writing, Version 5.0.19. Installing it is as easy as downloading it and unzipping or untarring it. Here's the directory structure you get when you do this:

 jakarta-tomcat-5.0.19 _  _bin  Binary files  _  _common  Classes used by code and web applications  _  _classes  Common Java classes  _  _endorsed  Endorsed Java classes  _  _lib  Common Java classes in .jar format  _  _conf  Configuration files  _  _logs  The server's log files  _  _server  Internal Tomcat classes  _  _shared  Shared files  _  _temp  Temporary files  _  _webapps  Directory to use for web applications  _  _work  Scratch directory for holding temporary files  

The webapps directory here is the important one; at least in terms of writing web applications; it's where to install your JSPs and servlet applications.

In this chapter, we're going to store examples in a directory named ch11 , which is a subdirectory of the Tomcat webapps directory. Note that this new directory must itself have a subdirectory named WEB-INF , which must have two subdirectories, classes and lib :

 webapps _  _ch11  The folder for Chapter 11 examples  _  _WEB-INF  Information about Chapter 11's web applications  _  _classes  Java classes used by Chapter 11's web applications  _  _lib  JAR files used by Chapter 11's web applications  

Note that although the WEB-INF , classes , and lib directories are empty here, they have to exist, or Tomcat can't serve files to the browser. We'll store the examples in this chapter in the ch11 directory.

11.1.4 See Also

Recipe 11.2 on starting Tomcat; Chapter 1 in Tomcat: the Definitive Guide (O'Reilly); Chapter 4 in JavaServer Pages (O'Reilly) ; Chapter 9 in Eclipse (O'Reilly).



Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

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