Tomcat4.01 Raiders (transfer)

xiaoxiao2021-03-06  61

Author: Dull Knife

One: Introduction

Tomcat is an important sub-project in the Jakarta project, which is selected by the JavaWorld magazine.

2001 most innovative Java Product (Most Innovative Java Product), but it

Is Sun's official recommended servlet and JSP container (specific visible / R

Http://java.sun.com/products/jsp/tomcat/), therefore it is more and more software

The company and developers' love. The latest specifications for servlet and JSP can be in the new version of Tomcat.

Realization.

Two: Installation and configuration

The latest version of Tomcat is 4.0.1, this version uses a new servlet container Catalina, complete / r

A Servlet2.3 and JSP1.2 specification are implemented. Note that your system must have JDK1.2 before installation.

The upper version.

(1): Installation

1: Windows platform

Download Jakarta-Tomcat-4.0.1.exe from Tomcat, follow the general Windows program

When you install the step, you can install Tomcat and install it automatically look for your JDK and JRE position.

2: Linux platform

Download Jakarta-Tomcat-4.0.1.tar.gz, unzip it to a directory.

(2): configuration

Run Tomcat requires setting java_home variables

Set java_home = c: / jdk (Win98, use in MSDOS mode, or put in autoexec.bat)

Export java_home = / usr / local / jdk (Used under Linux, put it in / etc / bashrc or / etc / profile)

(3): operation

After setting, you can run the Tomcat server, enter the bin directory of Tomcat, Win98

Startup starts Tomcat, Linux with startup.sh, the corresponding shutdown Tomcat command is

Shutdown and shutdown.sh.

Enter http: // localhost: 8080 / test in the browser after startup, due to Tomcat itself

There is a web server function, so we don't have to install Apache, of course, it can also be integrated with Apache

Together, the following will be introduced.

Below you can test their own JSP and servlet examples.

Three: Application

(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 you are True, you can get the actual host name of the remote client by calling the request.getremotehost () to the DNS query. If false is not performed, it 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 (functionality is similar to Logger, its Prefix and SUFFIX attributes 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

And http: // localhost: 8080 / manager / stop? Path = / examples Start and close the Examples application, respectively.

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.

(4) Integration with Apache

Although Tomcat can also make a web server, but it has a speed ratio of static HTML than Apache, and its / R

As a web server, the function is far less than Apache, so we want to integrate Apache and Tomcat / R.

Come.

We use the Linux system as an example.

Download the Apache 1.3.22 source code from the Apache website, then configure the installation as follows

Apache:

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 that the configure command specifies the target installation directory and joins DSO (Dynamic Shared

Object) Support, note that you must not forget this option.

Then download the WebApp module, put the mod_webapp.so file after decompression into Apache

Libexec directory, edit the httpd.conf under Apache's confed, and add / r on this file

The following three lines:

LoadModule WebApp_Module Libexec / Mod_Webapp.so

WebAppConnection WarpConnection Warp localhost: 8008

WebAppDeploy Examples WarpConnection / Examples / EXAMPLES /

The first line is to join the WebApp module. If you do not add DSO support when compiling Apache, you cannot use it.

LoadModule Directive, the second line specifies the connection of Tomcat and Apache, the third line specifies the deployment of that / R

Application, the format of these two instructions is 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, Port port with you.

Tomcat's configuration file server.xml lasts the last few lines to be consistent. The document is as follows:

Port = "8008" MINPROCESSORS = "5" maxprocessors = "75"

Enablelookups = "True"

Acceptcount = "10" debug = "0" />

******

Application Name consistent with the app name you deployed in Tomcat, URL PATH specifies access this / R

The URL applied. For example, the above example can be accessed by http: // localhost / examples /

Examples application in Tomcat.

(5): Chinese issues

General JSP's garbled problem can be solved by adding <% @ page contenttype = "text / html; charset = GB2312"%> by joining in JSP, as for servlet's chaos

The code can use the httpserveletRequest.setCharacTeeEncoding function provided in servlet2.3. For more detailed Chinese issues, please see / r

Chinese character encoding problem in jsp / servlet.

Four: Summary

Tomcat as a servlet (JSP is also compiled into a servlet) container, its application prospect is very

Ok, if you combine with JBOSS, you can implement Sun's J2EE specification (using JBoss as EJB service / R

. JBoss's official website also provides JBoss integrated Tomcat3.2 * for download. Another one

Source Application Server (ENHYDRA) is also based on Tomcat, which provides a more friendly management interface, and deploying applications is also simpler and more powerful.

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

New Post(0)