javaweb entry --- web server with HTTP protocol basis

  About the web above the foundation in the end is what the web, as well as local Java developers need to master. This article will answer what web server, how to use? There are the basics of http protocol.

web server

    Large web server concept is very broad, but in plain terms, this means that the website server, which is built on the Internet and on some computer program resides. Or again it simply, your computer to install the server software and connect to the Internet, then you can say that a computer server, right is so simple, is not rocket knowledge. But all aspects of performance is relatively low it is. Generally companies have specialized powerful personality can install the memory calculator big server software, if someone visited the company's engine room, so that one black box is a server.

It was noted that where I marked red, server software, yes this is our daily development will inevitably be used to, after the developer completed development projects, the need to configure the project to the server software on the line after the user through the customer end path or browser to access the server project is located, to request the resources he needs.

So what are some of the server software market it? Here is a brief introduction of several as understanding of:   

1, Apache is the world's most widely WEB server, the main advantage is that open source code, there is an open development team, as well as its support for cross-platform application portability. Apache modules supported by very rich, although less than other lightweight WEB server in speed and performance, is part of heavyweight products, memory consumption is also higher than other WEB server.

PS: the Apache Software Foundation requires the students to find out a little, apache is an open source public interest organizations, the development had to do it to know him, the purpose of the organization by providing hardware, communication tools and business infrastructure, so as Open Collaboration software development projects backing. The organization and development of the project are basically open source, which is free, such as tomcat server, maven project management software, etc., etc. There are many.

 

    2, Lighttpd is a website specifically for high-performance, secure, fast, good compatibility and flexible WEB Server environment, it has low memory overhead and low CPU share, good performance, as well as modules and so on. Support FastCGI, CGI, Auth, Output compression, URL rewriting and important functions such as Alias, are lightweight WEB server.

 

    3, Tomcat is an open source, Java-based web applications running servlet container and JSP Web applications, Tomcat server is performed according to the servlet and jsp specifications, so it can be said Tomcat server implementation of the Apache-Jakarta norms and than most commercial software application server is better, however, tomcat handling of static files and high concurrency is relatively weak.

 

    4, IBM WebSphere is a fully functional, open WEB application server, its Java-based application environment to build, deploy and manage Internet and Intranet Web applications. Compared to other popular WEB server, the number of applications is very small.

 

    5, IIS WEB is a service component that allows WEB server to publish information on the public Intranet or the Internet, including WEB server, FTP server, NNTP server and SMTP servers, one for web browsing, file transfer, e-mail and news services send and other aspects, it makes things publish information on the Internet has become a very easy. It provides WEB server functions as an extension ISAPI programming interface, but also provides Internet, you can achieve query and update the database.

 

    6, Nginx is a high-performance HTTP server and reverse proxy, can choose efficient epoll, kqueue, eventport most network I / O model, in the case of high concurrent connections, and can support up to 50,000 concurrent connections number In response, the memory and system resources, CPU and other consumption is very low, running very stable.

Each server to download and install the online tutorial is very large, there is no difficulty, but the point to note:
such as the commonly used tomcat server to download the installation is complete, click in the bin directory satrtup.bat intend to start the server when a black flash across the window? The first thing to note is necessary to have run tomcat jdk environment, mainly because there is no JAVA_HOME variable, turn on your computer, create a new environment variable named JAVA_HOME in the Advanced configuration, and then copy the contents of your computer before the path where the jdk bin paste the variable value, and then re-edit the value of the variable Path, at the beginning of% JAVA_HOME% \ bin; to the beginning of the variable value. The principle is because the configuration file server.xml tomcat, the need to access the path name java_home environment, and if you is not configured, an error occurs.

  For example several ways to configure the tomcat project:

Directory: bin: Tomcat run files lib: jar package need to use the conf Tomcat: Tomcat runtime files generated
first way to deploy: webapps: storage project needs to run, webapps in the dynamic configuration items must be the WEB-INF WEB -INF file must be exported to the project web.xml file in webapps: project export package lead to war, war will automatically unzip the package when the server is started

If you do not want to configure webapps in the project, in addition to the items copied to the webapps

The second way in server.xml in the Host tag, the new <Context docBase =: path "D \ path where the project" = "/ abc />
value docBase property: value of the path where the project path attribute: Browse access to the project is in the name
server.xml conf file in the Tomcat file folder

Under Catalina \ localhost directory, create a third way xxx.xml file in the Tomcat conf directory \
name in the browser to access the project's file name xxx.xml

  

  HTTP protocol:

  Browser Access Project: protocol + ip address port number + + + project file path name.

  Usually when the Internet you need to enter the URL, the URL http beginning always with the words, then the http in the end what is it?

  

HTTP: HyperText Transfer Protocol Hypertext Transfer Protocol. The browser and the server protocol
browser requests to the server, the server browser response, the HTTP protocol transmission between
like commonly known as the provisions of the agreement, so that the requester can recognize and respond to each end
1. High-level protocol TCP / IP-based
2. the default port number: 80
3. based on a request / response model: a primary response corresponding to the request

 

As well as the corresponding file protocol, message protocol, then it is popular, we have written to, right? We must start with Hello xxx, two blank spaces at the beginning of the text, and finally need Yours sincerely, xxx and xxxx xx xx day. This is a format that can be said a protocol, a letter of agreement between the recipient and the people, the only way you write, I can understand. You communicate with foreigners, you speak Chinese, he said his own language, that is certainly different, then you need to use a wide range of English as a protocol, we all speak English, have to comply with English grammar, so two people can communication.

So say this I am sure you all understand, http protocol is the browser (client) and the intermediate server protocol, in compliance with the protocol server can resolve the request from the browser, the browser can parse the response from the server.

To the Google Chrome browser, for example, visit the web page, click to open the Developer Tools Network, you can clearly see the request line General, request header requestHeaders, response format and content of the head responseHesders.

Client request message (Request): The client sends a request to the HTTP server format such as:
request line (request line): mode request url request protocol request / release
request header (header) request header name: request header value
request an empty line : empty line
request data: request parameter post encapsulation message

server response message: (reponse)
status line
message header
response body

Request method: HTTP protocol request There are 7 embodiment, there are two commonly
get: request parameters in the request line, after Hurl
url length of the request is limited to
post: request parameters in the request body
url length of the request is not limited

 

HTTP Three things to note:

HTTP is a connectionless: Meaning No limitation is attached only one request per connection. Client server processes the request, and after receiving the response the client
that is disconnected. In this way you can save transmission time

HTTP is a stateless: HTTP protocol is a stateless protocol, stateless means that no protocol for transaction processing and memory. If the lack of state means that
the subsequent processing required in front of the information, it must be retransmitted, which may result in increased transmission of data for each connection. On the other hand, it does not require the server
when the response to previous information it faster

HTTP is an independent media: This means that, as long as the client and server know how to handle the data content of any type of data can be sent via HTTP.
The client and server specify the appropriate MIME-type content type

 

 

 Common request headers:

User-Agent: browser tells the server, I access the browser version you are using information
useful: You can get information on the server side of the head, solve the compatibility problem browser
Referer: header in the request if Referer keys and values, Description from the page jump over,
use: there are statistics such as Baidu promotion of websites, from the point into the Baidu, Referer value is the Baidu website
security chain such as movie connections have wanted to play movies, found not cool favorably to the jump, do not play

 

 

Results After a brief introduction, we should be able to read a map:

  The red circle and out of place compared to server-side program we have a basic understanding. Then later to explain the contents of the yellow circle, it is how the server processes the request and respond to it?

 

Guess you like

Origin www.cnblogs.com/zhengcheng-java/p/11260212.html