The files in the Tomcat directory are detailed

Source: Internet
Author: User
Tags add time response code sessions xsl

One, tomcat background (turn)

Since JSP release, the introduction of a variety of JSP engine. After completing the development of GNUJSP1.0, the Apache group began to consider developing a JSP server that could provide Web services directly on Sun JSWDK, and of course supporting the Servlet, so that Tomcat was born. Tomcat is an important subproject in the Jakarta Project, selected by Javaworld Magazine as the most innovative Java product of the 2001, and it is the official recommended servlet and JSP container for sun. So it's more and more popular with software companies and developers. The latest specification for servlet and JSP can be implemented in a new version of Tomcat. Second, Tomcat is a completely free software that anyone can download freely from the Internet. The combination of Tomcat and Apache is quite perfect.

second, Tomcat directory

Tomcat

|---bin Tomcat: Store startup and shutdown Tomcat scripts;

|---conf Tomcat: Store different profiles (Server.xml and Web.xml);

|---Doc: storing tomcat documents;

|---Lib/japser/common: a library file (JARS) that stores the needs of Tomcat operations;

|---Logs: store log files for tomcat execution;

|---src: storing tomcat source code; (This depends on what tomcat you downloaded)

|---webapps:tomcat's main Web publishing directory (including application examples);

|---Work: Store the JSP generated class file after compiling;

three, Tomcat class loading

Bootstrap ($JAVA _home/jre/lib/ext/*.jar) actually double-clicking the jar directly will also make Tomcat run.

System ($CLASSPATH/*.class and the specified jar)

Common (classes,lib,endores Three subdirectories under the $CATALINA _home/common)

Catalina (the classes and LIB directories under the $CATALINA _home/server/are only visible to Tomcat)

&shared (the classes and LIB directories and $catalina_home/lib directories under the $CATALINA _home/shared/) are visible only to Web applications, not to Tomcat WEBAPP ($WEBAPP/ web-inf/* is visible only for this Web application Classes/*.class Lib/*.jar)

The order in which classes and resources are loaded is:

1,/web-inf/classes

2,/web-inf/lib/*.jar

3, Bootstrap

4, System

5. $CATALINA _home/common/classes

6. $CATALINA _home/common/endores/*.jar

7. $CATALINA _home/common/lib/*.jar

8. $CATALINA _home/shared/classes

9. $CATALINA _home/shared/lib/*.jar

Four, server.xml configuration introduction:

The following describes the basic configuration information in this file, and for more specific configuration information, refer to the Tomcat documentation:

Server:

1, port to specify a ports, this port is responsible for listening to turn off Tomcat request

2. Shutdown specifies the command string to be sent to the port

Service:

1. Name specified service

Connector (indicates the connection between client and service):

1. Port specifies the port number to be created on the server side and listens for requests from the client on this port.

2. Minprocessors the number of threads created at server startup to process requests

3. Maxprocessors the maximum number of threads that can be created to handle requests

4, Enablelookups If true, you can call Request.getremotehost () DNS query to get the actual hostname of the remote client, if False is not a DNS query, but return its IP address

5, Redirectport specified server is processing an HTTP request, received an SSL transfer request redirected after the port number

6. Acceptcount specifies the number of requests that can be placed in the processing queue when the number of threads that can be used to process requests is used, and requests that exceed this number are not processed.

7, ConnectionTimeout specifies the number of times to timeout (in milliseconds)

Engine (Represents a request processor in a specified service to receive and process requests from connector):

1. defaulthost Specifies the host name of the default processing request, which is at least the same as the Name property value of one of the host elements

Context (Represents a Web application):

1, the path of the DocBase application or the path that the war file holds

2, path represents the prefix of the URL for this Web application, so the URL for the request is

http://localhost:8080/path/****

3, reloadable This property is very important, if true, Tomcat will automatically detect the application's

/web-inf/lib and/web-inf/classes directory changes, automatic loading of new applications, we can

To change the application without having to restart Tomcat

Host (represents a virtual host):

1, name specifies the host name

2, appbase application Basic directory, that is, the directory where the application is stored

3, Unpackwars If true, then Tomcat will automatically extract the war file, or not to understand the pressure, run the application directly from the war file.

Logger (log, debug, and error messages):

1. CLASSNAME specifies the class name used by Logger, and this class must implement the Org.apache.catalina.Logger interface.

2, prefix specifies the log file prefix

3, suffix specify the suffix of log file

4, timestamp If true, the log file name to add time, as follows

Example: Localhost_log.2001-10-04.txt

Realm (a database that holds the username, password, and role):

1. CLASSNAME specifies the class name used by realm, and this class must implement the Org.apache.catalina.Realm interface.

Valve (Functionality similar to logger, whose prefix and suffix properties are interpreted in the same way as in logger):

1, ClassName specified valve use of the class name, such as with Org.apache.catalina.valves.AccessLogValve

Class can record access information for an application

directory(specify where log files are stored):

1, pattern has two values, common way to record the remote host name or IP address, user name, date, the first line of the requested string, HTTP response code, the number of bytes sent. The combined way is more than the common record value.

Five, Web.xml configuration introduction:

1, default (welcome) file Settings

 in Tomcat4\conf\web.xml,<welcome-file-list> the same meaning as the default file in IIS.

<welcome-file-list>

<welcome-file>index.html</welcome-file>

<welcome-file>index.htm</welcome-file>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

 2, the error file settings

<error-page>

<error-code>404</error-code>

<location>/notfilefound.jsp</location>

</error-page>

<error-page>

<exception-type>java.lang.nullpointerexception</exception-type>

<location>/null.jsp</location>

</error-page>

If a file resource is not found, the server will report 404 errors, according to the above configuration will call \webapps\root\notfilefound.jsp.

If the execution of a JSP file produces nullpointexception, it will call \webapps\root\null.jsp

 3, settings for session timeout

Set the expiration time of the session, the unit is minutes;

<session-config>

<session-timeout>30</session-timeout>

</session-config>

 4, filter settings

<filter>

<filter-name>filtersource</filter-name>

<filter-class>project4. Filtersource</filter-class>

</filter>

<filter-mapping>

<filter-name>filtersource</filter-name>

<url-pattern>/wwwservlet</url-pattern>

 (<url-pattern>/haha/*</url-pattern>)

</filter-mapping>

filter £ º

1) authentication filtering authentication Filters

2) log and audit filtering logging and Auditingfilters

3) Image Transformation Filter Image Conversionfilters

4) data compression filtering compressionfilters

5) encryption Filter Encryption Filters

6) tokenizing Filters

7) resource access event-triggered filtering filters that Triggerresource access events xsl/t filtering xsl/t filters

9) content Type Filter Mime-type chain filter to pay attention to the order of listeners, such as: first safe filtering, then resources,

Then the content type and so on, this order can be set itself.

Vi. Management

1, User Configuration

Before you perform a specific Tomcat management, add a user to Tomcat so that the user has permission to administer.

Open the Tomcat-users.xml file in the Conf directory and add the following line in the appropriate location:

<user name= "user" password= "user" roles= "Standard,manager"/>

Then start Tomcat, enter http://localhost:8080/manager/in the Browser, pop-up dialog box, enter the user above

Name and password.

2 , application list

When you enter http://localhost:8080/manager/list in the browser, the browser will display the following information:

ok-listed applications for virtual host localhost

/ex:running:1

/examples:running:1

/webdav:running:0

/tomcat-docs:running:0

/manager:running:0

/:running:0

The information shown above is the path to the application, the current state, and the number of sessions connected to the program.

3. Reload the application

Enter Http://localhost:8080/manager/reload?path=/examples in the browser, and the browser displays the following:

ok-reloaded application at the context Path/examples

This means that the example application mount succeeds, and if we set the Reloadable property of the Server.xml context element to true, there is no need to reload the application this way because Tomcat automatically mounts.

4, display session information

Enter Http://localhost:8080/manager/sessions?path=/examples in the browser, and the browser displays the following:

Ok-session Information forapplication at the context Path/examples Default maximum session inactive

Interval minutes

5. Start and close the application

In the browser, enter http://localhost:8080/manager/start?path=/examples and

http://localhost:8080/manager/stop?path=/examples Start and close the examples application separately.

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.