Shortest tomcat and tomcat

Source: Internet
Author: User

Shortest tomcat and tomcat

1. What is a server?

The so-called server is actually a program written by someone else. The server has two capabilities.

A. It helps us manage resources.

B. resources can be released to the outside world for external access.

2. What resources are there?

A. Static resources: the file itself will not change with the access process. What are common static resources?

(1) html file (2) css or js (3) Audio and Video or image.

B. Dynamic Resources: we have written some programs that can run on the server. The program will change with the execution process.

(1) servlet (2) jsp (3) action and so on.

3. Server Type

A. Static Resource Management Server: apacheHttpServer (in fact, httpServer can also manage dynamic resources, but it does not enable dynamic resource management by default. Httpserver cannot process our java programs, but some other scripting languages can. For example, ruby ..)

B. Dynamic Resource Management Server: it can help us run programs written in java.

(1) web Container | tomcat container (Open Source): This type of container features only some technical points in javaEE.

(2) Application Server | javaEE container (paid): This type of server is characterized by implementing all the technical points on the javaEE platform. Weblogic jboos...

Tomcat: an open-source free server of apache. This server is still widely used in China.

The tomcat server only implements some technical points on the javaEE platform. For example, jsp, servlet, and jdbc.

4. javaEE

The javaEE platform is actually a collection of technical points. Each technical point is a solution to a certain field. Common JavaEE technologies include servlet, jsp, jdbc, jndi, javamail, jta, ejb, jpa, jsf, and javaBean.

Common versions: javaEE1.3, javaEE1.4, javaEE5.0, and javaEE6.0.

5. Relationship between servlet/jsp, tomcat and JavaEE versions

TOMCAT4--J2EE1.3---SERVLET2.3/JSP1.2

TOMCAT5--J2EE1.4--SERVLET2.4/JSP2.0

TOMCAT6---J2EE5.0---SERVLET2.5/JSP2.1

TOMCAT7---J2EE6.0----SERVLET3.0

6. tomcat version

Tomcat4.x, tomcat5.x, tomcat6.x, tomcat7.x, and tomcat8.x

7. tomcat installation

A.exe File

B .rar file, decompress it directly.

During installation, you should note that tomcat should not be stored in a directory named Chinese.

Add CLASS_PATH = "% JAVA_HOME %" \ lib to the environment variable;
8. tomcat structure directory

A. bin ----> This directory stores some bat or sh files. How to start tomcat:

1). Click startup. bat to start tomcat.

2) Run catalina. bat in the black window and run the following command: start stop to close

3) Close the shutdonw. bat container or directly close the black window.

B. conf ---> some configuration files are stored in the directory xml

Server. xml: this file is mainly used to complete the overall configuration file for tomcat. For example, you can configure the port number in this file and the host name for service access.

<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"/>

You can also configure the encoding method and modify the value in the port to specify the port number you want tomcat to listen.

C. lib ----> some jar files are stored in this directory. The jar files here are mainly classified into two categories:

1) tomcat's own jar

2) implement some standard implementation classes (such as jsp servlet...) under the javaEE Platform ...)

D. log ----> stores all tomcat log files. If you want to know the printing information of the Black window at startup, go to this directory and find the catalina. log file. You can see the relevant records in this file.

E. temp ----> some temporary files generated by tomcat during runtime are stored in this directory. Whether these files exist does not affect tomcat running, so the contents in this directory can be deleted. However, the temp folder cannot be deleted.

F. webapps ----> This directory stores the resources that need to be managed by tomcat. The project war package can be placed here and tomcat is started. Then the project can run.

G. work ----> This directory mainly stores the original files and class files compiled by tomcat for jsp. When the program is modified, but there is no modification effect, you can delete the project content and try again.

9. tomcat project deployment Method

A. Put it in the webapps directory.

Static deployment:

The Webapps directory of Tomcat is the default application directory of Tomcat. When the server starts, all applications under this directory will be loaded. Therefore, you can package the JSP program into a war package and place it in the directory. The server will automatically unbind the war package and generate a folder with the same name under this directory. A war package is a jar package with a special format. It compresses all the content of a web program. You can use many development tools such as Eclipse in the IDE environment for packaging. You can also run the cmd command: jar-cvf mywar. war myweb

The default application directory webapps can also be changed. Open the server. xml file in the conf directory of Tomcat, find the following content, and modify the appBase.

 <Host name="localhost" appBase="webapps"           unpackWARs="true" autoDeploy="true"           xmlValidation="false" xmlNamespaceAware="false">

 

B. Modify the host node of server. xm. Add <Context path = "/access resource directory" docBase = "e:/xxx"/>

In the Tomcat configuration file, a Web application is a specific Context. You can deploy a JSP application in the new Context in server. xml. Open the server. xml file and create a Context in the Host tag. The content is as follows.

    <Context path="/hello" docBase="D:\ workspace\hello\WebRoot" debug="0" privileged="true">    </Context>

Or

<Context path="/myapp" reloadable="true" docBase="D:\myapp" workDir="D:\myapp\work"/>

Or

<Context path="/sms4" docBase="D:\workspace\sms4\WebRoot"/>

Note:

Path is a virtual path, which is required for page access;

DocBase is the physical path of the application;

WorkDir is the working directory of the application. It stores the files generated during the running process related to the application;

Debug sets the debug level. 0 indicates that the minimum information is provided, and 9 indicates that the maximum information is provided;

When privileged is set to true, Tomcat Web applications are allowed to use the Servlet in the container;

If reloadable is true, tomcat will automatically detect changes to the application's/WEB-INF/lib and/WEB-INF/classes directories, automatically load new applications, you can change the application without restarting tomcat to achieve hot deployment;

Hot deployment of antiResourceLocking and antiJARLocking is a parameter that needs to be configured. The default value "false" avoids updating a webapp. Sometimes Tomcat cannot completely delete the old webapp, usually a jar package under the WEB-INF/lib is left behind and Tomcat must be closed to be deleted, which leads to automatic deployment failure. Set to true. Tomcat copies the corresponding source files and jar files to a temporary directory when running the corresponding webapp.

D. find or create a folder (Catalina ----> localhost -----> project name to access the resource in the conf directory. xml -----> <Context ...... />) in the conf directory, create the Catalina \ localhost directory, and create an xml file in the directory. The name cannot be obtained at will. It must be the same as the name after path, according to the following path configuration, the xml name should be hello (hello. xml), the content of the xml file is:

<Context path="/hello" docBase="E:\workspace\hello\WebRoot" debug="0" privileged="true"></Context>

10. Access the Project address

Format of the server resource to be accessed: Protocol: Address (Domain Name): Port/Resource Directory/Resource Name

URL: Uniform Resource Locator (Uniform Resource Locator) Protocol: Address: Port/Resource Directory/Resource Name

URI: Uniform Resource Identifier (Uniform Resource Identifier) Resource Directory/Resource Name

11. tomcat User Configuration

After using Tomcat, the above page appears, click "Tomcat Manager" to enter the account and password when you have to configure the tomcat-users.xml to fit your own fast and secure login!

  <?xml version='1.0' encoding='utf-8'?>    <tomcat-users>      <role rolename="tomcat"/>      <role rolename="manager"/>      <role rolename="admin"/>      <user username="admin" password="" roles="tomcat,admin,manager"/>  </tomcat-users>

The tomcat-users.xml file contains the registered users of all Tomcat servers, including role and user information.

1. role parameter: Some user permissions, such as admin and Tomcat, are saved in Tomcat;

2. User parameter: This data item contains data such as User name, User password, User permission, and User description.

12. http protocol

An http request consists of three parts: request line, message header, and request body.

GET Request to obtain the resource identified by Request-URI;

POST attaches new data to the resource identified by Request-URI;

The HEAD Request obtains the Response Message Header of the resource identified by Request-URI;

The PUT Request server stores a resource and uses Request-URI as its identifier;

The DELETE Request server deletes the resource identified by Request-URI;

TRACE Request information received by the server, mainly used for testing or diagnosis;

CONNECT is retained for future use;

OPTIONS requests query the server performance, or query resource-related OPTIONS and requirements.

Related Article

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.