Reprint http://panfuy.iteye.com/blog/1224665 Server.xml Configuration Introduction
The following is the basic configuration information in this file, and more specific configuration information is found in the Tomcat documentation
Server
Port, which is responsible for monitoring the request to close Tomcat.
SHUTDOWN Specifies the command string to send to the port
Service
NAME Specifies the service names
Connector (indicates a connection between the client and the service):
PORT Specifies the port number to be created on the server side and listens for requests from the client at this fracture
Minprocessors the number of threads that were created when the server started processing requests
Maxprocessors maximum number of threads that can be created to process requests
Enablelookups If True, you can make a DNS query by calling Request.getremotehost () to get the actual hostname of the remote client and, if False, to return its IP address instead of a DNS query
REDIRECTPORT Specifies the port number that the server is redirecting when it receives an SSL transfer request when it is processing an HTTP request
ACCEPTCOUNT Specifies the number of requests that can be placed in the processing queue when all the threads that can be used to process the request are used, and requests that exceed this number will not be processed
CONNECTIONTIMEOUT specifies the number of times to time out (in milliseconds)
Engine (representing the request processor in the specified service, receiving and processing requests from connector):
DEFAULTHOST Specifies the default host name for processing requests, which is at least the same as the Name property value of one of the host elements
Context (which represents a Web application, typically a war file, for specific information about the war, see the servlet specification):
DocBase the path to the application or the path where the war file is stored
Path represents the prefix of the URL for this Web application, so the requested URL is http://localhost:8080/path/****
Reloadable This property is important, and if true, Tomcat automatically detects changes in the application's/web-inf/lib and/web-inf/classes directories, automatically loading new applications, We can change the application without having to restart Tomcat
Host (represents a virtual host):
NAME Specifies the host name
AppBase Application Base directory, which is the directory where the application is stored
Unpackwars If True, Tomcat will automatically unzip the war file, otherwise, run the application directly from the war file
Logger (indicates log, debug, and error messages):
CLASSNAME specifies the class name used by Logger, this class must implement the Org.apache.catalina.Logger interface
Prefix specifying the prefix of the log file
Suffix specifying the suffix of the log file
Timestamp if true, the log file name is added to the time, as in the following example: Localhost_log.2001-10-04.txt
Realm (the database that holds the user name, password, and role):
CLASSNAME specifies the class name used by realm, this class must implement the Org.apache.catalina.Realm interface
Valve (functionally similar to logger, whose prefix and suffix attributes are explained in the same way as in logger):
CLASSNAME specifies the class name that Valve uses, such as using the Org.apache.catalina.valves.AccessLogValve class to record access information for an application
directory specifies where log files are stored
Pattern has two values, the common method records the remote host name or IP address, the user name, the date, the first line of the requested string, the HTTP response code, and the number of bytes sent. Combined way more value than common way record
Attention:
In the default server.xml, the realm element only has a classname attribute set, but this file also contains several examples (commented out) that are validated by JDBC connection to the database, and we can implement container security management through the realm element (Container Managed Security).
There are also elements, such as Parameter,loader, where you can get information about these elements through the Tomcat documentation.
----------------------------------------------------------------------
Configuration of the context in Tomcat
After we have developed a web app, we need to publish the app to a Web server so that other users can access it. In the area of Java Web Development, we typically use Tomcat as our web server for testing or formal deployment.
Typically we package the Web app into a war format and then copy it to the Tomcat WebApp directory for publishing, under normal circumstances, Tomcat will automatically unzip the war file and generate the corresponding directory, and will dynamically create the corresponding context path for that Web application in memory. For example, our war file is Sample.war, then the extracted directory is the Sample directory, the dynamic creation of the context path in memory is/sample. The default behavior in the development phase is acceptable, but in the case of a formal deployment, we usually need to modify the application's context path to suit our needs.
If we want the user to simply enter the domain name to access our sample application, we need to modify the Tomcat context settings. There are two ways to set the context path, one is to modify the {Tomcat_home}/conf/server.xml file, and the other is to set up a context fragment file to be placed in the WebApps directory. We introduce the first method here.
Open the Server.xml file with any text editor, add the <Context> node under the <Host> node, and set the Path,docbase,debug and Reloadable properties as follows:
Xmlcode: XML code <?xml version= "1.0" encoding= "UTF-8"?> <Server> <listener classname= " Org.apache.catalina.mbeans.GlobalResourcesLifecycleListener "/> < Listener classname= "Org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/> <listener classname= "Org.apache.catalina.mbeans.ServerLifecycleListener"/> <GlobalNamingResources> <Environment name= "Simplevalue" type= "Java.lang.Integer" value= "/> <Resource auth= "Container" description= "user Database that can be updated and saved " name= "Userdatabase" type= " Org.apache.catalina.UserDatabase " pathname=" conf/ Tomcat-users.xml " factory=" Org.apache.catalina.users.MemoryUserDatabaseFactory "/> </ globalnamingresources> <Service name= "Catalina" > <Connector port= "8080" redirectport= "8443" minsparethreads= " " connectiontimeout= "20000" maxsparethreads= " maxthreads=" maxhttpheadersize= "8192" > </connector > <Connector port= "8009" redirectport= "8443" protocol= "AJP /1.3 "> </Connector> &lT engine defaulthost= "localhost" name= "Catalina" > <realm classname= "Org.apache.catalina.realm.UserDatabaseRealm"/ >
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.