With the advent of the Catalina Servlet Engine, Tomcat version 4 claims that its performance has been improved, making it a Servlet/JSP Container worth considering. However, there are few file resources that can help you get started with Tomcat, and there are only a few books, and some materials on the Jakarta website are not very clear.
Let's take a step-by-step look at the Tomcat installation process, and then discuss how to use some Tomcat 4/JSP functions to build Web applications.
What is Tomcat?
Tomcat is a Java-based Web Application Software container that runs open source code, servlet, and JSP Web application software. Tomcat is supported by Apache-Jakarta sub-projects and maintained by volunteers from the open source code Java Community. Tomcat Server is executed according to servlet and JSP specifications. Therefore, we can say that Tomcat Server implements Apache-Jakarta specifications and is better than most commercial application software servers.
Install Tomcat 4
To start using Tomcat 4, you must download at least the Java Development Kit (JDK) 1.2 and Tomcat 4 installation packages, which are ZIP files and Windows Installation packages. Once you have installed these two data packets, you must add two environment variables: JAVA_HOME and atat_home. JDK will be installed in the JAVA_HOME directory, while Tomcat 4 will be installed in the TOMCAT_HOME directory.
If you install Tomcat through the Windows Installer, you can use the menu options to start Tomcat, or open a command prompt window to enter the TOMCAT_HOMEin directory and run the startup. bat/sh file. Open a browser and enter the URL http: // localhost: 8080. The default Tomcat page will appear in front of you.
Preliminary reading of Web Application Software
Before we start, let's review the components contained in the next Web application software. Java Servlet specification defines Web applications as a set of servlets, HTML pages, classes, and other resources that are bundled and run on multiple containers from multiple marketers. In Tomcat, these resources are placed in a special directory structure under the TOMCAT_HOMEwebapps folder. For a sample of a Web application (myapp), the directory structure is as follows:
TOMCAT_HOMEwebappsmyappWEB-INFclasseslib
The Myapp directory is regarded as the root directory of Web application software. All JSP, HTML, JavaScript files and other resources are located under this directory. The WEB-INF directory contains the resources used by the application, but the WEB-INF is not in the public document root directory. All files in this directory cannot be accessed by the client. The class directory (under the WEB-INF) contains the servlets, beans, and Utility Classes required to run myapp. In some instances (log4j), attribute files are placed in the directory of the class. The Lib directory (under the WEB-INF) contains Java archive files (JARs), such as a JDBC drive or tag library, which myapp relies on. If a class appears in the JAR file and in the class directory, the Class Loader loads the one in the class directory.