Tomcat4.01 Full Raiders

Source: Internet
Author: User
Tags add http request implement string version jboss access port number
Strategy in view of the many people to tomcat configuration and usage puzzled, special on the Internet search an article emergency.

==================
Tomcat4.01 Full Raiders
One: Introduction
Tomcat is an important subproject in the Jakarta Project, selected by the editor of Javaworld Magazine
The most innovative Java products of the 2001 (Most innovative Java product), and it
Is the official recommended servlet and JSP container for sun Company (see
http://java.sun.com/products/jsp/tomcat/), so that it's getting more and more affected by software
The likes of the company and the developers. The latest specifications for the servlet and JSP are available in the new version of Tomcat
to implementation.

Second: Installation and configuration
The latest version of Tomcat is 4.0.1, which uses a new servlet container Catalina, complete
To achieve the servlet2.3 and jsp1.2 specifications. Note that your system must have jdk1.2 installed before installation to
On the version.

(i): Installation
1:windows Platform
Download Jakarta-tomcat-4.0.1.exe from the Tomcat website and follow the general Windows program
Mount the steps to install Tomcat, it will automatically find the location of your JDK and JRE when installed.


2:linux Platform
Download the jakarta-tomcat-4.0.1.tar.gz and extract it into a directory.

(ii): Configuration
Running Tomcat requires setting the Java_home variable
Set JAVA_HOME=C:/JDK (Win98, used in msdos mode, or put into Autoexec.bat)
Export JAVA_HOME=/USR/LOCAL/JDK (used under Linux, put in/ETC/BASHRC or/etc/profile)

(iii): operation
After setting up, you can run the Tomcat server, enter Tomcat's Bin directory, Win98
Startup boot Tomcat,linux with startup.sh, and the corresponding turn off Tomcat command for
Shutdown and shutdown.sh.
You can enter the http://localhost:8080/test in the browser after startup because Tomcat itself has
Has the functionality of a Web server, so we don't have to install Apache, of course it can also be integrated with Apache
Together, as described below.
Below you can test its own JSP and servlet samples.

Third: Application

(i): directory structure
The directory structure of Tomcat is as follows:
Directory Name: Introduction
Bin: Storing startup and shutdown Tomcat scripts
Conf: Contains different profiles, Server.xml (Tomcat's primary profile) and Web.xml
Work: Store the JSP generated class file after compiling
WebApp: Store application examples, and the applications you want to deploy will be placed in this directory
Logs: Storing log files
Lib/japser/common: These three directories primarily contain the jar files required by Tomcat


(ii): Introduction to Server.xml Configuration
Below we will talk about the basic configuration information in this file, more specific configuration information see the text of Tomcat
File
Server
PORT specifies the ports that are responsible for listening for requests to shut down Tomcat
SHUTDOWN Specifies the command string to be sent to the port
Service
Name to specify service names
Connector (indicates the connection between client and service):
PORT Specifies the port number to be created on the server side and listens for requests from the client on this fracture surface
Minprocessors number of threads created at server startup to process requests
Maxprocessors the maximum number of threads that can be created for processing requests
Enablelookups If True, you can enter by calling Request.getremotehost ()
Row DNS queries to get the actual host name of the remote client, or FALSE for DNS queries, but
return its IP address
Redirectport the specified server is processing an HTTP request and has received an SSL transfer request redirect
The port number
ACCEPTCOUNT specifies that when all available processing requests are used, the number of threads can be placed everywhere
The number of requests in the queue, and requests exceeding this number will not be processed
ConnectionTimeout specify the number of times to timeout in milliseconds
Engine (represents a request processor in a specified service, receiving and processing requests from connector
Request):
DEFAULTHOST Specifies the host name of the default processing request, which is at least the same as that of one of the host elements
The Name property value is the same
Context (represents a Web application, usually a war file, for specific information about war)
servlet specification):
DocBase the path of the application or the path that the war file holds
Path represents the prefix of the URL for this Web application, so the URL for the request is
http://localhost:8080/path/****
Reloadable This property is very important, and if true, Tomcat automatically detects the application
Changes in the/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 host name
AppBase Application Base directory, that is, the directory where the application resides
Unpackwars If True, Tomcat will automatically extract the war file, or else it won't understand the pressure.
Run the application directly from the war file
Logger (for logs, debugging, and error messages):
CLASSNAME specifies the class name used by logger, which must implement the
Org.apache.catalina.Logger interface
prefix specifies the prefix of the log file
suffix specifies the suffix of the log file
Timestamp if true, the log file name is added to the time, as follows
Example: Localhost_log.2001-10-04.txt
Realm (a database that holds user names, passwords, and role):
CLASSNAME specifies the class name used by realm, which must implement the Org.apache.catalina.Realm interface
Valve (function is similar to logger, its prefix and suffix properties are explained and one of the logger
Sample):
CLASSNAME specifies the class name used by valve, such as the Org.apache.catalina.valves.AccessLogValve class to record the application's access letter
Interest
directory specifies where log files are stored
Pattern has two values, common way to record the remote host name or IP address, username, date, paragraph
One-line requested string, HTTP response code, number of bytes sent. Combined way than common
Way to record more value

Attention:
1: After I test, I set the context of the Path= "", Reloadable=true, and then put a
War file to the WebApps directory, the result Tomcat could not detect this file (restart Tomcat to
And unzip the file, Tomcat automatically detects the new application. If you cannot automatically
To detect the war file, we can deploy the application using the methods in the management below.


2: In the default server.xml, the realm element sets only one classname property, but this file
Also contains several examples of validation connected to the database through JDBC (commented out), through the realm
Element we can implement container safety management (Container Managed security).


3: There are some elements we haven't introduced, such as Parameter,loader, you can go through Tomcat
Documents to obtain information about these elements.

(iii): Management

1: Configuration
Before we go into specific management, we add a user to Tomcat so that the user has access to the
Line management.
Open the Tomcat-users.xml file in the Conf directory and add the following line in the appropriate location:


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


Note: The last part of this line must be/>,tomcat's document dropped/symbol, if no/symbol
, the application will not be accessible when Tomcat is reset. You can see through the Logs/catalina.out file.
To the details of this error.


Then restart Tomcat, enter http://localhost:8080/manager/in the browser, and bounce
Out of the dialog box, enter the user name and password above.


2: Application list
Enter Http://localhost:8080/manager/list in the browser and the browser will display the following
The 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 above is the path to the application, the current state (running or stopped), and the
The number of sessions connected to the program.

3: Reloading the application
Enter Http://localhost:8080/manager/reload in the browser?
Path=/examples, the browser appears as follows:

ok-reloaded application at the context Path/examples

Indicates that the example application is loaded successfully if we will server.xml the context element's
The Reloadable property is set to True (see table above), there is no need to reload the application this way
Order, because Tomcat will automatically load.

4: Show Session information
Enter http://localhost:8080/manager/sessions in the browser?
Path=/examples, the browser appears as follows:

Ok-session information for application in context Path/examples
Default maximum session inactive interval minutes

5: Start and close the application
Enter Http://localhost:8080/manager/start?path=/examples in the browser
And Http://localhost:8080/manager/stop?path=/examples are started and closed separately
Closed examples applications.

6: Deploy and Undo Deployment
There are two ways to organize a war, one is to organize files according to a certain directory structure, one is a suffix of
War, so there are two ways to deploy it:
(1): In the browser input: Http://localhost:8080/manager/install?
Path=/examples&war=file:/c:examples

The war deployment organized by directory structure


(2): if input: http://localhost:8080/manager/install?path=/examples&war=jar:file:/c:examples.war!/
The war deployment will be organized according to the compressed package, noting that the second half of this URL must have a!/number.
It can be accessed with http://localhost:8080/examples after deployment.

Enter in the browser: Http://localhost:8080/manager/remove?path=/examples will undo the application you just deployed.


(iv): with Apache integration
Although Tomcat can also be used as a Web server, its handling of static HTML is not as fast as Apache, and its
As a Web server, the functionality is far less than Apache, so we want to integrate Apache and Tomcat
To.
Let's take a Linux system as an example.
Download the apache1.3.22 source code version from the Apache web site, and then configure the installation with the following command
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 The Configure command specifies the target installation directory and joins the DSO (Dynamic Shared
Object), note that you must not forget this option.

Then download the WebApp module, will extract the mod_webapp.so file into Apache
Libexec directory, edit Apache httpd.conf in the Conf directory, add at the end of this file
Three lines below:

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 the compilation of Apache does not increase the DSO support, you can not use
LoadModule directive, the second line specifies the connection between Tomcat and Apache, and the third line specifies the deployment of the
Applications, these two instructions use the following format:

Webappconnection [Connection Name] [provider] [Host:port]
Webappdeploy [application name] [connection name] [URL path]

Where connection name specifies the connection name, provider can only be Warp,port port with your
The Tomcat configuration file server.xml the last few lines to remain consistent. The documents are as follows:


<service name= "Tomcat-apache" >
<connector classname= "Org.apache.catalina.connector.warp.WarpConnector"
Port= "8008" minprocessors= "5" maxprocessors= "75"
Enablelookups= "true"
Acceptcount= "Ten" debug= "0"/>
******
</Service>

Application name is consistent with the application name you deployed in Tomcat, URL path specifies access to this
The URL to apply. For example, the above example can be accessed through http://localhost/examples/.
Examples applications in Tomcat.

(v): Chinese question
General JSP garbled problem can be in the JSP by adding <%@ page contenttype= "text/html;charset=gb2312"%> to solve, as for the servlet's chaos
Code can be used in the httpserveletrequest.setcharacterencoding function provided in servlet2.3. For more detailed Chinese questions, please see
The problem of encoding in Jsp/servlet.

Four: Overview
Tomcat as a servlet (JSP is also compiled into a servlet execution) container, and its application prospects are very
Well, if you combine with JBoss, you can implement the Sun Java EE specification (using JBoss as an EJB service
Device). JBoss's official website also provides an integrated tomcat3.2* of JBoss for downloading. The other one opens
The source's application server (Enhydra) is also based on Tomcat, which provides a more user-friendly management interface and is simpler and more powerful to deploy applications.

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.