(1): directory structure
Tomcat's directory structure is as follows:
Directory Name: Introduction
BIN: Store startup and close Tomcat script
Conf: Contains different profiles, server.xml (main configuration files for Tomcat) and Web.xml
Work: Class file generated after the JSP compile
WebApp: Store application examples, after you have to deploy applications, you have to put this directory.
Logs: Store log files
LIB / JAPSER / COMMON: These three directory mainly store the JAR files required for Tomcat
(2): Server.xml configuration introduction
Below we will tell the basic configuration information in this file, more specific configuration information see Tomcat's text
files
Server:
Port specifies a port, this port is responsible for monitoring the request to close Tomcat
ShutDown specifies the command string sent to the port
Service:
Name Specifies the name of Service
Connector (represents the connection between the client and the service):
Port specifies the port number to be created by the server side and listen to the request from the client in this fracture.
MINPROCESSORS server starts the number of threads created when the server is started
MaxProcessors maximum number of processes that can be created
Enablelookups If true, you can call REQUEST.GETREMOTEHOST () into / r
Row DNS query to get the actual host name of the remote client, if false does not perform DNS queries, but
Returns its IP address
RedirectPort specifies that the server is processing the HTTP request to receive an SSL transmission request after redirect / r
Port number
AcceptCount specifies that when all the number of threads that can be used, you can put it everywhere.
The number of requests in the queue will not be processed more than this number.
ConnectionTIMEOUT Specifies the time number of timeout (in milliseconds)
ENGINE (Recommend, and Processing Processor, Receive, and Processing from Connector / R)
begging):
DefaultHost Specifies the host name of the default processing request, which is at least one of the Host elements.
Name attribute value is the same
Context (Represents a web application, usually a WAR file, about the specific information of WAR / R
Servlet specification):
The path to the DOCBASE application or the path stored in the WAR file
PATH indicates the prefix of the URL of this web application, so the requested URL is
Http: // localhost: 8080 / path / ****
Reloadable This property is very important. If true, Tomcat automatically detects the application / R
The / Web-INF / LIB and / WEB-INF / CLASS content changes, automatically load new applications,
We can change the application without counting Tomcat
Host (Represents a virtual host):
Name Specifies the host name
AppBase application base directory, ready to save your application
UnpackWars If True, Tomcat will automatically decompress the WAR file, otherwise it will not decompress.
Run the application directly from the WAR file
Logger (indicating log, debugging, and error message):
ClassName Specifies the class name used by the Logger, this class must be implemented
Org.apache.catalina.logger interface
Prefix Specifies the prefix of the log file
Suffix Specifies the suffix of log files
TimeSTAMP If you are True, you want to join the time in the log file name, as follows
Example: LocalHost_log.2001-10-04.txt
Realm (indicating the database stored by the username, password, and Role):
ClassName Specifies the class name used by Realm. This class must implement org.apache.catalina.Realm interface Valve (the functionality is similar to Logger, its prefix and suffix attribute explains one in logger
kind):
ClassName Specifies the class name used by Valve, and uses org.apache.catalina.valves.accessLogvalve class to record the application's access letter
interest
Directory specifies the location where the log file is stored
Pattern has two values, Common mode records remote host name or IP address, user name, date,
A string of the request, HTTP response code, the number of bytes sent. Combined method than Common
Mode record value more
note:
1: After I tested, I set up PATH = "", reloadable = true, then put one / r
WAR files to the webapps directory, the result cannot detect this file (recover Tomcat
In order to decompress this file, Tomcat will automatically detect this new application. If you can't automatically
Detecting a WAR file, we can use the methods described below to deploy applications.
2: Dealm elements are only set with a classname property, but this file is set.
There are also several examples connected to the database via JDBC (commented), through Realm
Elements we can implement container safety management.
3: There are still some elements we have not introduced, such as parameter, loader, you can pass Tomcat
Document acquire information of these elements.
(3): management
1: Configuration
Before conducting specific management, we add a user to Tomcat, so that this user has permission to enter / r
Management management.
Open the Tomcat-Users.xml file under the conf directory, add the following line in the appropriate location:
Note: The last part of this line must be />, Tomcat's document, if there is no / symbol
If the Tomcat restarts, the application will not be accessed. You can watch by logs / catalina.out file
Details to this error.
Then you will restart Tomcat, type http: // localhost: 8080 / manager /, floors in the browser
Out of the dialog, enter the username and password above.
2: Application list
Enter http: // localhost: 8080 / manager / list in your browser, the browser will display
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 above information is the path of the application, the current state (running or stopped), with this / R
The number of session connectors connected.
3: Re-load the app
Enter http: // localhost: 8080 / manager / roomad in your browser?
Path = / example, the browser is shown below: OK - Reloaded Application At Context Path / Examples
Indicates that the EXAMPLE application is loaded, if we use the server.xml's context element
The RELOADABLE property is set to TRUE (see the above table), there is no need to reload the application in this way.
Preface, because Tomcat is automatically loaded.
4: Show session information
Enter http: // localhost: 8080 / manager / sessions?
Path = / example, the browser is shown below:
OK - Session Information For Application At Context Path / Examples
Default Maximum Session Inactive Interval 30 Minutes
5: Start and close the app
Enter http: // localhost: 8080 / manager / start? Path = / esamples in the browser
And http: // localhost: 8080 / manager / stop? Path = / examples separately
Close Examples application.
6: Deployment and revocation deployment
WAR has two organizations, one is to organize files on a certain directory structure, one is a suffix
WAR's compression package, so its deployment method has two:
(1) Enter: http: // localhost: 8080 / manager / install?
Path = / examples & war = file: / c: Examples
WAR deployment will be organized according to the directory structure
(2): If you enter: http: // localhost: 8080 / manager / install? Path = / examples & war = jar: file: / c: Examples.war! /
The WAR deployed by the compression package will be deployed, note that the second half of this URL must have! / 号.
You can access by http: // localhost: 8080 / examples after deployment.
Enter: http:// localhost: 8080 / manager / remove? Path = / examples will revoke the application just deployed.