JAKARTA-Tomcat Confident Chinese User Guide Part 2
Elements and their descriptions of the most important element in the serverserver.xml file. Server defines a Tomcat server. Generally, you don't have to worry too much. Server elements can include Logger and ContextManager type Logger, this element defines a logger object, each Logger There is a name to logo, and there is a record logger output and redundancy level (describe this log level) and a path to the log file. Usually there is a servlet's logger (servletContext.log ()), JSP and Tomcat run Logger. ContextManagerContextManager Description A set of ContextInterceptors, Requestinterceptor, Context and their Connectors configuration and structure. ContextManager has several features that are provided: 1. Record debugging debug level 2. WebApps /, conf /, logs / All defined environments. Used to launch Tomcat to start outside Tomcat_HOME. 3. Name of Work Directory ContextInterceptor & RequestintercePtor These listeners These listeners These listeners are listened to events that occur in ContextManager. For example, ContextInterceptor Listening to Tomcat and terminating events, requestInterceptor monitors different stages of the user requesting to pass during its service process. Tomcat does not have to know too much about the listener; in addition, developers should know how this is how this is in Tomcat Implement a "global" type (such as security and each request log) ConnectorConnector indicates a connection to the user, whether it is through the web server or directly to the user browser (in a stand-alone configuration) .connector is responsible for managing Tomcat Request / Response of Work Threads and Read / Write Connections to Different Users The Configuration contains the following information: 1. Handle 2. Handle TCP / IP Port 3. The TCP / IP of the handle server port is slightly After we will describe how to configure Connector. Connext Each context provides a subordinate directory to Tomcat, which you place your web project. Each context contains the following configuration: 1. The path placed with the ContextManager main directory. 2. Record debugging information debug level 3. Overloaded flag. When developing servlets, 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, using another server profile and setting relational environment manager's directory property you need to set the following files in the main directory: Ø A webApps / directory (if you have generated) - All WAR file trophy 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 profile Ø logs / - all log files will replace Tomcat_Home / Logs / Record to this directory Ø Work / - Relational environment work directory such as the ContextManager.home property 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 the server as an independent run. But there are some problems to explain: 1. When processed the static page, Tomcat is not as fast as Apache. 2. Tomcat is not as configured as Apache. 3. 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, serving a service for the site's static page request, 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. Obviously, you must know what to pass on the servlet container. We still need to provide additional configuration items into the conjugate of Web-Server or Servlet-Container. L Whether the Tomcat process can be achieved, we still need to provide the TCP / IP hostname / port number of configuration and Tomcat is listening. l You need to inform the web server interface library (so we can load in the start-up time) l Supply internal information such as where to record logs and how to record, and so on. All such information must appear in a Web server configuration or in a private configuration file used by the interface. Here's how to implement these configurations in Apache. Implementation on Apache
This section demonstrates how to configure Apache to work with Tomcat; and try to explain the configuration specification that may be used in depth. Other information can be found on the JSERV installation page.