Tomcat4.01 Raiders

xiaoxiao2021-03-06  201

Tomcat4.01 Raiders 1: Introduction Tomcat is an important subproject in the Jakarta project, which is selected as the most innovative Java product in 2001, while the Most Innovative Java Product, which is selected by JavaWorld Magazine. Recommended servlets and JSP containers (specifically available /RHTTP: //java.sun.com/products/jsp/tomcat/), so it is more and more loved by software companies and developers. The latest specifications for servlet and JSP can be implemented in the new version of Tomcat.

2: Installation and configuration Tomcat latest version is 4.0.1, this version uses a new servlet container Catalina, complete / r implementation servlet2.3 and jsp1.2 specification. Note that your system must have JDK1.2 or higher before installation.

(1): Installation 1: Windows platform download jakarta-tomcat-4.0.1.exe from the Tomcat website, install Tomcat, install the Tomcat, install it, you will automatically look for your JDK and JRE when installing steps.

2: Linux platform Download jakarta-tomcat-4.0.1.tar.gz, unzip it to a directory.

(2): Configuring the Tomcat need to set the java_home variable set java_home = c: / jdk (Win98, use in msdos mode, or put it in autoexec.bat) Export java_home = / usr / local / jdk (use under Linux, put it under Linux Between / etc / bashrc or / etc / profile)

(3): After running, you can run the Tomcat server, enter the bin directory of Tomcat, start Tomcat with Startup with Startup, linux with startup.sh, the corresponding shutdown Tomcat command is shutdown and shutdown.sh. Enter http: // localhost: 8080 / test in the browser after startup, because the Tomcat itself has a web server function, so we don't have to install Apache, of course, it can also be integrated with Apache, which will be introduced below. Below you can test their own JSP and servlet examples.

Three: Application

(1): Directory Structure Tomcat directory structure is as follows: Directory Name: Introduction BIN: Starts and close Tomcat Script CONF: Contains Different Profiles, Server.xml (Tomcat's primary configuration file) and Web.xml Work: Store JSP Class files after compiling WebApp: Store application example, after you have to deploy the application, you should also put it in this directory logs: Store log file lib / japser / common: These three directory mainly store Tomcat required JAR files

(2): Server.xml Configuration Introduction Let's describe the basic configuration information in this file, more specific configuration information See Tomcat's document server: port specifies a port, this port is responsible for monitoring the Tomcat request Shutdown Specifying the port Send Command String Service: Name Specifies the name of the service "Connector between the client and the service): port specifies the port number to be created by the server side, and the processing from the client's request minprocessors server starts creation Request Thread MaxProcessors Maximum Create Processing Request For Problem Enablelookups If true, you can get the actual host name of the remote client by calling the repaSt.getRemoteHost () into / r line DNS query, if false does not perform DNS Query, but returns its IP address redirectport specifies that the server is processing the HTTP request to receive an SSL transmission request. The port number acceptcount of the redirection / r specifies that when all the number of threads that can be used, can be put The number of requests in the processing queue exceeds this number of requests will not process the number of time (in milliseconds) engined (in milliseconds) ENGINE (in milliseconds) ENGINE (in milliseconds) ENGINE (Request / R) : DefaultHost Specifies the host name of the default processing request, which is at least the same CONTEXT with a name attribute value of one of the host elements (represents a web application, usually a WAR file, regarding the specific information of WAR / RSERVLET specification) : The path of the DOCBASE application or the path to the WAR file is stored correct to the URL of this web application, so the requested URL is http: // localhost: 8080 / path / **** Reloadable This property is very important, if For True, Tomcat automatically detects changes in the application / R / web-inf / lib and / web-inf / class directory, automatically loads new applications, we can change the application without counting Tomcat

Host (Represents a virtual host): Name Specifies the basic directory of the hostname AppBase application, that is, the directory where the application is stored. If True, Tomcat will automatically decompress the WAR file, otherwise it is not extracted, running the application directly from the WAR file. Logger (Represents log, debugging, and error message): classname Specifies the class name used by the Logger, which must implement org.apache.catalina.logger interface prefix Specifies the prefix for the log file specified by the Log file. If you are TRUE, LOG In the file name, you want to join the time, as follows: 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 (functionality is similar to Logger, its prefix and suffix attribute interpretation and logger): classname Specifies the class name used by Valve, such as using org.apache.catalina.valves.accessLogvalve class to record application access information Directory specifies that the location pattern of log files has two values, Common mode records the remote host name or IP address, user name, date, first line requested string, HTTP response code, and the number of bytes sent. Combined approaches more than the value recorded by the Common mode: 1: After I test, I set up PATH = "", reloadable = true, then put one / rwar file to the webapps directory, the result of Tomcat can't detect this file (heavy From Tomcat, and extract this file, Tomcat will automatically detect this new application. If the WAR file cannot be automatically detected, we can use the methods described below to deploy applications.

2: In the default server.xml, the Realm element only sets a className property, but in this file, several examples connected via JDBC to the database (commented), we can implement container security through Realm elements. Container Managed Security.

3: There are still some elements. We have not introduced, such as parameter, loader, you can get information about these elements through Tomcat documents.

(3): management

1: Before making specific management, let's add a user to Tomcat so that this user has permission to enter / r line 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, the Tomcat will not be able to access the application. You can see the details of this error by logs / catalina.out file.

Then recover Tomcat, enter http: // localhost: 8080 / manager /, will pop up in the browser, enter the username and password above.

2: Application list Enter http: // localhost: 8080 / manager / list in your 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 /: Running: 0

The above information is the path to the application of the application, the current state (running or stopped), the number of sessions connected to this / R program.

3: Re-load the application Enter http: // localhost: 8080 / manager / relocalhost: 8080 / manager / recocalhost: 8080 / manager / repline? Path = / example, the browser is shown below:

OK - Reloaded Application AT Context Path / Examples

Indicates that the Example application is loaded. If we set the reloadable property of Server.xml's Context element to True (see above), it is not necessary to reload the application using this manner because Tomcat will be loaded.

4: Display session information Enter http: // localhost: 8080 / manager / sessions? Path = / examples, browser is shown in the browser:

OK - Session Information For Application At Context Path / Examples Default Maximum Session Inactive Interval 30 Minutes

5: Start and close the app in the browser http: // localhost: 8080 / manager / start? Path = / example: 8080 / manager / stop? Path = / examples, start and close Examples application.

6: Deployment and revocation of WAR has two organizations, one is to organize files according to a certain directory structure, one is a compression package for a suffix, so there are two ways to deploy: (1): Browse 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! / Will press the WAR organization of the compression package to note this URL The second half must have! / Number. You can access by http: // localhost: 8080 / examples after deployment.

Enter: http:// localhost: 8080 / manager / remove? Path = / examples will revoke the application just deployed.

(4): Although Tomcat can also be a web server, it can handle the static HTML speed than Apache, and its / R is far less than Apache, so we want to integrate Apache and Tomcat / r comes. We use the Linux system as an example. Download the Apache 1.3.22 source version from the Apache website, then configure the installation of Apache using the following command:

MKDIR / USR / local / apache tar zxvf apache.1.32.tar.gz cd apache.1.32 ./configure --prefix = / usr / local / apache --enable-module = so make make install Note Configure Command Specify the target installation directory And join DSO (Dynamic Shared Object) support, pay attention to not forget this option.

Then download the WebApp module, and put the mod_webapp.so file into the Apache's libexec directory, edit the httpd.conf under the Apache's confed, and add / r in this file.

LoadModule WebApp_Module Libexec / Mod_Webapp.so WebAppConnection WarpConnection Warp Localhost: 8008 WebAppDeploy Examples WarpConnection / Examples /

The first line is to join the WebApp module. If you do not add DSO support when compiling Apache, you cannot use the loadModule command, the second line specifies the connection of Tomcat and Apache, and the third line specifies the deployment of that / R application. The two instructions use the format as follows :

WebAppConnection [Connection Name] [PROVIDER] [Host: Port] WebAppDeploy [Application Name] [Connection Name] [URL PATH]

Where Connection Name specifies the connection name, the Provider can only be WARP, the Port port is consistent with the last few lines of the last few rows of Tomcat's configuration file server.xml. The document is as follows:

******

Application Name consistent with the app name you deployed in Tomcat, the URL Path specifies the URL to access this / R application. For example, the above example can access the Examples app in Tomcat via http: // localhost / example.

(5): Chinese problem general JSP garbled problem can be solved by adding <% @ page contentty = "text / html; charset = GB2312"%> by joining in JSP, as for servlet2.3 can be used in servlet2.3 HTTPServeletRequest.setCharacterencoding function. For more detailed Chinese issues, please see the Chinese character encoding problem in / RJSP / servlet.

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

New Post(0)