Jakarta-tomcat Concise Chinese version of the user's guide first

Source: Internet
Author: User
Tags command line contains include variables version variable win32 tomcat
This document provides basic information about Tomcat. The main contents are as follows:
Tomcat Binary version installation
Main contents of Tomcat-related scripts
Main content related to Server.xml, Tomcat's main configuration file
How to set up a description of how Tomcat works with the host Web server
How to apply Tomcat configuration to a real-world web site
I hope this document is sufficient to enable new users to start using Tomcat. If you can't find anything, please (in the following order)
Find Tomcat FAQ
Find the Tomcat package list
Issue a problem with the Tomcat user mailing list
The answer to this question does not exist, and we encourage you to put the answer to the question in the Tomcat FAQ or this document. If you have comments or suggestions for this document, please send it to Tomcat's mailing list.

Getting Started
Tomcat is a servlet container with a JSP environment. The servlet container is a shell that can manage and activate the Servlet runtime based on the behavior of the user.
You can roughly divide the servlet container into the following categories:

Stand-alone servlet container
A part of a Web server is built in. refers to situations where a java-based Web server is used, such as a servlet container that is part of a javawebserver. The standalone servlet container is the default mode for Tomcat.
Most Web servers are not based on Java, so we can draw the following two types of container patterns.


In-process servlet container
The servlet container is the implementation of the Web server's plug-in and Java container. The Web server plug-in opens a JVM (Java Virtual machine) in the internal address space to enable the Java container to run internally. If there is a request to invoke the servlet, The plug-in will take control of the request and pass him (using JNI) to the Java container. In-process containers for multithreading, a single process server is appropriate and provides a good run speed, but scalability is insufficient.


Out-of-process container outside the process
The servlet container runs in an address space outside the Web server and as a combination of the Web server's plug-in and the Java container's implementation. The Web server plug-in and the Java container JVM communicate using the IPC mechanism (typically TCP/IP). When a request to call the servlet arrives , the plug-in will take control of the request and pass it (using IPC, etc.) to the Java container, the reaction time of the out-of-process container or the Out-of-process container engine is not as good as the process content device, but the Out-of-process container engine is better in many other comparable ranges (scalability, stability, etc.).
Tomcat can be used as a stand-alone container (primarily for development and debugging) and as an add-on to an existing server (currently supports APACHE,IIS and Netscape servers). That is, any time you configure Tomcat you have to decide how to apply it, such as selecting a second or third mode, You also need to install a Web server interface.
What's the difference between Tomcat and Jserv? is Tomcat Jserv?
This is a common misconception. Jserv is a container that is a servlet API2.0 compatible and is used with Apache. Tomcat is a fully rewritten container that is compatible with servlet API2.2 and JSP1.1.
Tomcat uses some code written for Jserv, especially the Apache interface for Jserv, but this is the only common one.
How do I install the Tomcat binary version?
Very simple, just:
Download zip/tar.gz any compressed files from the http://jakarta.apche.org/download/binindex.html place.
Unzip the file to a directory (such as: foo). A subdirectory will be generated, called Tomcat.
Convert to "Tomcat" directory set a new environment variable (tomcat_home) point to the directory of Tomcat you installed
WIN32 platform, type:
"Set Tomcat_home=foo\tomcat"
UNIX Platform:
If bash/sh environment, type: "Tomcat_home=foo/tomcat;export tomcat_home"
If TCSH environment, type: "Setenv tomcat_home Foo/tomcat"
Set the environment variable java_home the directory that points to your JDK, and then add the Java interpreter to your PATH environment variable.
All right! You can now run Tomcat and act as a standalone servlet container (mode one)
Start and close Tomcat
Start and close Tomcat using the script in the "Bin" directory.
Start:
uinx:bin/startup.sh
Win32:bin\startup
Shut down:
unix:bin/shutdown.sh
Win32:bin\shutdown
Tomcat directory Structure
Assuming you've unpacked Tomcat, you've got the following directory structure:
Directory Name--description
Bin
Include Startup/shutdown scripts
Conf
Contains a different configuration file,
Includes Server.xml (Tomcat's primary profile) and files that set defaults for different tomcat-configured Web applications Web.xml
Doc
Contains various Tomcat documents
Lib
Contains the jar file used by Tomcat. UNIX platform any files in this directory are added to Tomcat's classpath
Logs
Where Tomcat placed log files
Src
Servletapi source files. Don't be happy, these are just some empty interfaces and abstract classes that must be implemented within the servlet container
WebApps
Include examples of Web projects
Also you can Tomcat will create the following directories:
Work
Tomcat is automatically generated and places temporary files for the Tomcat runtime (such as compiled JSP files). If you delete this directory while Tomcat is running. JSP pages will not run.
Classes
You can create this directory to add some additional classes to the Classpath. Any class you add to this directory can find itself in the Tomcat classpath.
Tomcat's script
Tomcat is a Java program, so you can run it on the command line after setting up several environment variables. However, setting up each environment variable used by Tomcat and the following command-line parameters is tedious and error-prone. As a result, the Tomcat Development Group provides some scripts to make it easy to start and turn off Tomcat .
Note: These scripts are simply a convenient way to start and turn off Tomcat. You can modify them to customize Classpath, environment variables such as Path,ld_library_path, and so on, as long as the correct command line is generated.
What are these scripts? The following table lists the most important scripts for the general user.
Tomcat
The main script. Set the appropriate environment variables, including Classpath,tomcat_home and Java_home, and start TOMCAT with the appropriate command line arguments

Startup

Start Tomcat in the background. " How to replace the Tomcat start command

Shutdown

Turn off Tomcat. " How to replace the Tomcat Stop command


The most important script for the user is Tomcat (tomcat.bat/tomcat.sh). Other tomcat-related scripts serve as a simple portal to a single task-oriented tomcat script (setting different command-line arguments, etc.).


Carefully review the tomcat.bat/tomcat.sh, which runs as follows:

Steps under Unix:

If not specified, speculate tomcat_home

If not specified, speculate java_home

Setup Class_path contains:

1.${tomcat_home}/classes directory (if present)

Everything in 2.${tomcat_home}/lib's content

3.${java_home}/lib/tools.jar (This JAR file contains tool Javac, we need javac to process the JSP file.)


Run Java commands with command-line arguments that set the Java environment variable into tomcat.home, and Org.apache.tomcat.startup.Tomcat As the starting class. Also passes command-line arguments to Org.apache.tomcat.startup.Tomcat, for example:


Perform operations such as Start/stop/run

This tomcat process uses a path that points to server.xml.

For example, Server.xml is placed in Etc/server_1.xml and the user intends to start Apache in the background, type the following command line:

Bin/tomcat.sh Start–f/etc/server_1.xml

Steps under Win32: (slightly)


This shows that the Win32 version of the Tomcat.bat with the UNIX version of almost the same. In particular, it does not speculate on the value of Tomcat_home and Java_home, and does not put all jar files into the classpath.


Tomcat configuration file

Tomcat configuration is based on two profiles:

1.server.xml-tomcat Global configuration file

2.web.xml-Configuring a different relational environment in Tomcat


This section describes how to use these files. We will not include the internal mechanisms of web.xml, which drill down into the details of the servlet API, so we'll discuss the Servler.xml content and web.xml usage in the Tomcat environment.


Server.xml

Server.xml is the main configuration file for Tomcat. Complete two goals:

1 provides the initial configuration of the Tomcat component.

2 illustrates Tomcat's structure, meaning, so that Tomcat completes the start and builds itself by instantiating the component, as specified in Server.xml

The following table describes the important elements of the Server.xml species:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.