[Java Basics Review] Tomact and HTTP section summary.

Source: Internet
Author: User
Tags apache tomcat

Objective:
just came back early today and summed up the basics of Tomcat and HTTP.

1, Tomcat
Web-related concepts
Web: The meaning of a Web page resource includes all resources on the server.
Web Resource classification:
Static resources: Resources that do not change content
Dynamic resources: Resources that can change content
Web technology:
Static Web technology: HTML CSS JS, etc.
Dynamic Web technology: servlet JSP, etc.
In Java, Dynamic Web resource development technology is collectively known as Javaweb, and our course focuses on how to use Java technology to develop dynamic Web resources, dynamic Web pages.
Software Architecture:
C/S: client/server For example: League of Legends QQ
b/S: Browser/server For example: page game Web version of QQ
Web communication relies on the request-response mechanism to complete
Common Web servers
Servers: Hardware servers and software servers
Weblogic:oracle company large toll Web server supports all Java EE specifications
WEBSPHERE:IBM company large toll Web server supports all Java EE specifications
Tomcat:apache organization small and medium-sized free Web server support servlet and JSP specification
Tomcat
Installation: Decompression Apache-tomcat-7.0.53.zip
Start: *\apache-tomcat-7.0.53\bin\startup.bat
Test: http://localhost:8080
solution to small problems:
Port issues:
1, Netstat-aov View the PID of the 8080 port number and then go find it. Close this process
2, modify port number: Open *\apache-tomcat-7.0.53\conf\server.xml
Change the value of port around 70 rows
<connector port= "8888" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
The default port number for HTTP is 80;
Environment variables:
If installed, the Catalina_home will appear on the environment variable: the path of the tomcat to be started
Close:
1. Point x
2.ctrl+c
3.shutdown.bat
Directory of Tomcat:
Bin: directory where executable files are stored
Conf: directory where configuration files are stored
Lib:tomcat and application run-time required jar packages
Logs: Log file for storage
Temp: Storing Temporary files
WebApps: directory where Web projects are stored
Work: The Java file and the. class file that corresponds to the JSP file are stored
Web project directory
MyWeb (catalogue)
|
|----Web-inf (directory, not accessible through the browser, through Java technology can be accessed)
| |
| |---classes (directory): The stored Java bytecode file.
| |---web. XML (file): Core configuration file for a project
|----Html,css,js ...
|
Publish Project
Method 1: Copy the project to the Tomcat/webapps directory
Access path: http://ip:port/project name/executed resource
Mode 2: Modify \apache-tomcat-7.0.53\conf\server.xml---not recommended
Modify 170 lines Add the following code under the <context path= "/project Name" docbase= "Project disk path"/>
Access path: http://ip:port/project name/executed resource
Method 3: Add an XML file to *\apache-tomcat-7.0.53\conf\catalina\localhost
The contents are:
<context docbase= "Disk path to project"/>
The name of the file is the project name

Tomcat and Eclipse integration
War pack
Mode 1: Package via MyEclipse
Mode 2: Go to the project directory, select all the files, add to the zip file to select the zipped format, and finally change the suffix name to. War
Mode 3: Enter the project directory and use the JAR command to fight the war package JAR-CVF package name. War */


2,http Protocol

Hypertext Transfer Protocol, based on TCP protocol, the default port number is 80;
Request
Format: Request line request Header Request body
The first line in the Request line request information
Format: Resource path Protocol/version requested by request
Example: get/day0801/hello.html http/1.1

Request Header
accept:text/html,image/*--Support data type MIME format large type/small type
Accept-charset:iso-8859-1--Character Set
Accept-encoding:gzip--Compression supported
ACCEPT-LANGUAGE:ZH-CN--language environment
HOST:WWW.ITCAST.COM:80--Access the host
If-modified-since:tue, Jul 18:23:51 GMT-Last modified time for cache files
Referer:http://www.augmentum.com/index.jsp--from which page, anti-theft chain
user-agent:mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Cookies
Connection:keep-alive--Link status
Date:tue, Jul 18:23:51 GMT--time
Focus: Cookie Referer if-modified-since accept-encoding
Request body: There is a blank line between the request header
Only the POST request has the request body
Parameters
Username= ' Zhangsan ' &password= ' 123 '
response
Format: Response line response Header response body
The first line in the Response line response information
Format: Description of status code for Protocol/version Status code
Example: http/1.1 304 not Modified

Status code:
1XX: In Request
2XX: Request Response Complete
Common 200 Response success
3XX: Further browser operation is required
Common Status Codes:
304: The file does not change, please look for the cache
302: Still need to turn
4XX: User Operation error
404: The resource found does not exist
5XX: Server Error
500: Server Error

Response header
Common response Headers
Location:http://www.augmentum.com/index.jsp--Jump direction
Server:apache Tomcat-Server model
Content-encoding:gzip--Data compression
CONTENT-LENGTH:80--Data length
CONTENT-LANGUAGE:ZH-CN--language environment
content-type:text/html; charset=gb2312--Data type
Last-modified:tue, Jul 18:23:51 GMT-Last modified
Refresh:1;url=http://www. augmentum.com--timed refresh
Content-disposition:attachment; Filename=aaa.zip--Download
SET-COOKIE:SS=Q0=5LB_NQ; Path=/search
Expires:-1--cache
Cache-control:no-cache--Cache
Pragma:no-cache--Cache
Connection:keep-alive--Connection
Date:tue, Jul 18:23:51 GMT
Focus: Set-cookie content-disposition last-modified content-type content-encoding Location
Response body
And the response header has a blank line between the
What the browser shows

[Java Basics Review] Tomact and HTTP section summary.

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.