Tomcat Chinese Manual

xiaoxiao2021-03-13  175

Entry time: 2004-10-18 21:28:24 Source: Seventh Channel This document provides basic information about Tomcat. The main contents are as follows: Tomcat binary version installation The main content of the script related to Tomcat is related to server.xml Content, Tomcat's primary configuration file How to set up Tomcat to work with the host web server How to apply Tomcat Configuring a realistic Web site I hope this document is enough to start using Tomcat. If you can't find someone, please ask ( Find the following order) Find Tomcat FAQ Find Tomcat Pack The one-way Tomcat user mailing list issues such a question of this question does not exist, we encourage the question of questions to add questions in Tomcat FAQ or this document. If you have advice or suggestions for this document, please The mailing list sent to Tomcat. Getting StartedTomcat is a servlet container with a JSP environment. Servlet container is a shell that can manage and activate servlet based on user behavior. Roughly can divide the servlet container into a few categories: The stand-alone servlet container has part of the web server. Refers to the use of Java-based web servers, such as servlet containers are part of JavaWebServer. Separate servlet container is the default mode of Tomcat. Most web servers are not based on Java, Therefore, we can derive the model of the following two containers. The servlet container servlet container in the process serves as a web server's plugin and the implementation of the Java container .Web server plugin opens a JVM (Java Virtual Machine) to open a JVM (Java Virtual Machine) in the internal address space Operation internally. If a request to call the servlet, the plugin will acquire the control of this request and deliver him (using JNI) to the Java container. Processor Content For multi-thread, the server is very suitable and provided Very good running speed, but the scalability is inadequate. The Servlet container Servlet container runs outside the address space other than the web server and the combination of the web server's plugin and the implementation of the Java container .Web server plugin and Java container JVM Communication is performed using the IPC mechanism (usually TCP / IP). When a request to call servlet arrives, the plugin will acquire the control of this request and deliver it (using IPC, etc.) to the Java container, process outer container, or Process outer container engines are not as followers, but process outer container engines are better (scalability, stability, etc.) in many other comparison. Tomcat can be used as a separate container (mainly It is for development and debugging) and can be used as an additional to existing servers (currently supporting Apache, IIS, and Netscape Server). That is, you must decide how to apply him, such as selecting the second or third mode, You still need to install a web server interface. What is the difference between Tomcat and JSERV? Tomcat is JSERV? This is a common misunderstanding. Jserv is Servlet API2.0 compatible with the container used with Apache .tomcat is a complete rewritten Containers compatible with Servlet API2.2 and JSP1.1.Tomcat use some code written for JSERV, especially Jserv's Apache interface, but this is the same. How to install Tomcat's binary version? Very simple, Simply: Download any compressed file from http://jakarta.apchex.ob/download/binIndex.html. Unzip this file to a directory (such as: foo). A subtalog will be generated Named "Tomcat". Convert to "Tomcat" directory Set a new environment variable (Tomcat_home) point to the Tomcat of Tomcat, type: "set tomcat_home = foo / tomcat" UNIX platform: such as a Bash / SH environment , Type: "Tomcat_home = foo / tomcat;

Export Tomcat_Home "If the TCSH environment, type:" setenv tomcat_home foo / tomcat "Set the environment variable java_home points to your JDK directory, then add the Java interpreter to your PATH environment variable. Ok! Now you can run Tomcat and as an independent Servlet Container (Mode 1) Starts with Close Tomcat Using Scripts in the "bin" directory launch and close Tomcat. Start: uinx: bin / startup.shwin32: bin / startup close: UNIX: bin / shutdown.shwin32: bin / shutdowntomcat directory Structure Hypothesis You have decompressed Tomcat, you have got the following directory structure: Directory Name - Description BIN contains Start / Close script Conf contains different profiles, including server.xml (Tomcat's primary configuration file) and for different Tomcat configurations Web Application Settings Defaults File Web.xmldoc Contains Various Tomcat Document Lib Contains Tomcat JAR Files. UNIX Platform Any files in this directory are added to Tomcat's ClassPath Logs Tomcat placed in Logs Tomcat placed in Logs Tomcat ServletAPI source files. Don't happy, these only some of the air interfaces and abstract class WebAPPs that must be implemented in the servlet container contains web project examples. Some you can create the following directory: Worktomcat automatically generates, place Tomcat Timatics (such as Compiled JSP files). If you delete this directory when you run. Thejsp page will not be able to run. Classes You can create this directory to add some additional categories to classpaths. Anything you add this directory can be Finding itself in Tomcat's class path Tomcat is a Java program, so you can run how to use the command line after setting several environment variables. However, set each environment variable used by Tomcat and the following command line parameters. And error. Therefore, Tomcat development group provides some scripts to make the startup and closing Tomcat easier. Note: These scripts are just a convenient way to start and close Tomcat. You can modify them to customize ClassPath, environment variables such as Path, LD_LIBRARY_PATH,, etc., as long as it produces a correct command line. What is these scripts? The following table lists the most important scripts for the general user. Tomcat main script. Set the appropriate environment variable, including ClassPath, Tomcat_Home and JAV A_HOME and use the appropriate command line parameter Start Tomcat Startup Start Tomcat in the background. The replacement of the Tomcat Start command Shutdown Close Tomcat. The Tomcat Stop command has a replacement method of the user's most important script is Tomcat (Tomcat.bat / Tomcat .sh). Other Tomcat-related scripts as a simple point-oriented Tomcat script (set different command line parameters, etc.). Carefully examine tomcat.bat / tomcat.sh, follows: in UNIX The step of the next step: If it is not specified, it is specified that tomcat_home is not specified, speculating java_home setting class_path contains: 1. $ {Tomcat_home} / classes directory (if present) 2. $ {Tomcat_home} / lib 3. $ {Java_home} /LIB/Tools.jar (This JAR file contains tool javac, we need JAVAC to handle the JSP file. Run the java command with the command line parameters with the setting Java environment variable, tall tomcat.home, and org.apache.tomcat. Startup.tomcat is started. At the same time, the command line parameter is also passed to org.apache.tomcat.Startup.tomcat, such as operation of start / stop / run, etc. This Tomcat process uses the path to Server.xml, such as Server. XML is placed in ETC / Server_1.xml and the user is intended to start apache in the background, the key is as follows: bin / tomcat.sh start? f /etc/server_1.xml steps under Win32:

(Omitted) It can be seen that the Win32 version of Tomcat.Bat is almost consistent with UNIX version. Especially in it does not speculate Tomcat_Home and Java_home value, and do not put all JAR files into the class path. Tomcat configuration file Tomcat Configuring two profiles: 1.Server.xml - Tomcat global configuration file 2.Web.xml - Configuring different relationships in Tomcat This section will tell how these files will contain these files. We will not contain Web.xml interior Mechanism, these internal mechanisms go deep into the details of the Servlet API, so we will discuss the usage of servler.xml content and web.xml in the Tomcat relational environment .Server.xmlserver.xml is the main configuration file of Tomcat. Complete two goals 1 provides the initial configuration of Tomcat components. 2 Description Tomcat structure, meaning, so that Tomcat completes the start and build itself by instantiation components, such as the following table specified in Server.xml Important elements: Elements and It describes the most important elements in the ServerServer.xml file. Server defines a Tomcat server. You don't have to worry too much. Server elements can contain logger and contextManager type Logger this element defines a logger object, each logger has A name demonstrates, there is also a record logger's output and redundancy level (describes this log level) and the path to the log file. There is usually a logger (servletContext.log (), JSP and Tomcat running Logger. ContextManagerContextManager Description A set of ContextInterceptor, RequestInterceptor, Context, and their Connectors configuration and structure. ContextManager has several features available: 1. Debug debugging levels 2. WebApps /, conf /, logs / and all have The basic location of the defined environment is used to make Tomcat can start in other directories outside Tomcat_HOME. 3. Working directory Name ContextInterceptor & RequestintercePtor These listeners These listeners These listeners These listeners These listeners These listeners These listeners are listened to events that occur in ContextManager. For example, Contextinterceptor listens Tomcat of Start and terminating events, requestInterceptor monitors different stages of the user requests to pass during its service process. Tomcat's administrator does not have to know too much about listener; in addition, developers should know how this is in Tomcat " Global "operation (such as security and each request log) ConnectorConnector represents a user's join, whether it is through the web server or directly to the user browser (in a stand-alone configuration) .connector is responsible for managing Tomcat's working thread and Request / Response of the port connected to different users. The configuration of the Connector contains the following information: 1. Handle 2. Handle 6 Handle Survey TCP / IP Port 3. The TCP / IP of the handle server port. We will In this document, describe how to configure Connector.Context Each context provides a subscriber directory that pointing to Tomcat of your web project.

Each context contains the following path, which is placed, can be the path associated with the ContextManager home directory. 2. Record debugging information debug level 3. Overloaded flag. When developing servlet, overload the rear SERVLET This is a very convenient feature that you can debug or use Tomcat to test the new code without stopping or restart Tomcat. To open the overload, set the reloadable to true. This takes time but detects changes More important things, in view of a new servlet when a mountable object is loaded, the class load trigger may throw some errors. To avoid these issues, you can set overloaded as a false, which will stop heavy Load function. Starting Tomcat from another directory as the default value will use Tomcat_home / conf / server.xml as a configuration file. The default configuration will use tomct_home as the basis of the relational environment. Use "-f / your / directory / server .xml option You can change this situation, using another server profile and setup relational directory properties you need to set the following files in the home directory:? A webApps / directory (if you have generated)? All WAR file trophies overwhelves this directory and all subdirectories will be added as a relational environment.? Conf / directory - You can save a special web.xml file and other profiles? Logs / - All log files will replace Tomcat_Home / Logs / Records to this directory? Work / - Relational environment work directory such as the ContextManager.home attribute in Server.xml is associated, will associate to the current work directory .web. XML about the web. A detailed description of the XML and Web project structures (including directory services and configurations) can be found in Chapters 9, 10, 14 of Servlet API SPEC. However, there is a small "characteristic" related to Tomcat. Tomcat allows users to define the default value of all the Web.xml of all relationship environments by putting the default web.xml into the confed directory. When establishing a new relationship environment, Tomcat uses the default web.xml file as the basics. Set and apply item-specific web.xml (web-inf / web.xml files for application items) to override these defaults. Set Tomcat and Apache Web Server Servers until now, we have not discussed Tomcat as servers Only a server that is running independently. However, there are some problems to explain: 1. Tomcat is not as fast as Apache when it is handled in the static page. 2. Tomcat is not as strong as Apache. 4 There are many websites that have been put in a particular Web Server for a long time, for example, using CGI scripts / server API modules / perl / php ... We can't assume that things left will be discarded. Based on the reasons, one Realistic website recommends using a web server, such as Apache, providing services for the static page of the website, and use Tomcat as a servlet / jsp plugin. We are not prepared to discuss each different configuration, we will: 1. Cover Web Server Basic Behavior 2. Explain what configuration requires 3. Example web server operation on Apache is simply, the web server is always waiting for HTTP requests from the client. When the request arrives, the server will provide everything necessary to meet this request. Add a servlet container to some extent change this behavior. But the server still needs to process the following factors: load the servlet container interface library and initialize (before processing the request). When a request is received, check if it belongs to a servlet, if so, the interface library receives this request and processes. On the other hand, the interface library needs to know that he will serve some request, usually a mode based on the request, and where to guide this request. When the user wants to set the configuration using the virtual host, things become more complicated, or want multiple developers to develop JVMs for developing but use different servlet containers. We will discuss these two issues. The necessary configuration should consider the most obvious configuration is that the servlet URL has a representation of servlet in the servlet container.

转载请注明原文地址:https://www.9cbs.com/read-129062.html

New Post(0)