1. Servlet preparation and servlet preparation

Source: Internet
Author: User

1. Servlet preparation and servlet preparation
Author: Chan Lou wangyue (http://www.cnblogs.com/yaoyinglong) 1. HTTP protocol

HTTP is the upper layer of TCP/IP protocol. TCP is responsible for ensuring that files sent from one network node to another can arrive at the destination as a complete file. IP is an underlying protocol that routes data blocks (data packets) to the destination. HTTP is another network protocol that relies on TCP/IP to send requests and responses from one place to another.

1.1 HTTP URL

The first introduction of URL is that only after you enter the url address in your browser will there be subsequent HTTP requests and HTTP responses.

The rul address is parsed as follows:

Tell the server that I can acceptText, webpage, Image]

Accept-Charset: ISO-8859-1 [Accept character encodingIso-8859-1]

Accept-Encoding: Gzip, compress [AcceptableGzip, compressCompressed Data]

Accept-Language: En-us, zh-cn [Browser support in English]

Host: Www.sohu.com: 80 [The host I am looking for isWww.sohu.com: 80]

If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT [Tell the server that my buffer contains this resource file. The file time is...]

Referer: Http://www.sohu.com/index.jsp [Tell the server where I am from,This message header is commonly used inPreventing leeching]

User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0 )[Tell the server that the browser kernel]

Cookie [Cookie]

Connection: Close/Keep-Alive [Keep connection. After sending data, I will not close the connection for 30 seconds.]

Date: Tue, 11 Jul 2000 18:23:51 GMT [The browser sendsHttpRequest time]

A request is as follows:

Location: Http://www.baidu.org/index.jsp [ask the browser to relocate the url]

Server: Apache tomcat [tell the browser that I am tomcat]

Content-Encoding: Gzip [tell the browser how to use gzip]

Content-Length: 80 [tell the browser to send back data in section 80]

Content-Language: Zh-cn [Chinese supported]

Content-Type: Text/html; charset = GB2312 [content format: text/html; encoding: gab2312]

Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT [tell the browser the time when the resource was last updated]

Refresh: 1; url = http://www.baidu.com [how long to go, refreshToHttp://www.baidu.com]

Content-Disposition: Attachment; filename=aaa.zip [tell the browser that a file is downloaded]

Transfer-Encoding: Chunked [Transfer Encoding]

Set-Cookie: SS = Q0 = 5Lb_nQ; path =/search [Details]

Expires:-1 [tell the browser how to cache the page (IE)]

Cache-Control: No-cache [tell the browser how to cache the page Firefox]

Pragma: No-cache [tell the browser how to cache the Page]

Connection: Close/Keep-Alive[Keep connection1.1YesKeep-Alive]

Date: Tue, 11 Jul 2000 18:23:51 GMT

The Expires object header field specifies the response expiration date and time. To enable the proxy server or browser to update the cache after a period of time (when accessing the previously visited page again, load the page directly from the cache, shorten the response time and reduce the server load, we can use the Expires object header field to specify the page expiration time. Eg: Expires: Thu, 15 Sep 2006 16:23:12 GMT

A request response is as follows:

When you place a web application elsewhere, instead of webapps, you need to use it)

--> Web. xml: Configure the web application in this file (the web application is equivalent to a web site)

--> Tomcat-users.xml: This file is used to configure the tomcat user password and permissions.

LibDirectory: This directory contains the jar packages required to run tomcat.

LogsDirectory: stores logs. When we need to view logs,Useful! When tomcat is started incorrectly, You can query the information.

WebappsDirectory: in this directory, place our web applications (web sites ).

Work: Working directory: This directory is used to store the corresponding server files and. class files generated after jsp access.

3.4 standard directory structure and homepage configuration of Web Applications

A complete standard Web application catalog structure is as follows:

<Welcome-file-list> <welcome-file> index. jsp </welcome-file> </welcome-file-list>

In this way, the Web server returns the home page to us without the Resource Name.

3.5 manage virtual directories

In most cases, when we put web applications directly under the webapps directory, tomcat will automatically manage them. However, if we want tomcat to manage web applications in other directories, what should I do? Context path="/Myweb2"DocBase ="D: \ web2"/>

Myweb2: Indicates the web name entered during access. Actually, the resources in d: \ web2 are retrieved.

"D: \ web2 ":The physical path to manage.

Suppose we want to access the index. jsp file in d: \ web2,Address entered during actual access: http: // localhost: 8088/myweb2/index. jsp

③ Restart tomcat to take effect (because tomcat is waiting to use dom technology to parse xml files .)

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.