Interview questions-java web-network communication

Source: Internet
Author: User

What is the structure of the 1.HTTP response?

The HTTP response consists of three parts:
Status code: Describes the status of the response. Can be used to check whether the request was completed successfully. In the case of a request failure, the status code can be used to identify the cause of the failure. If the servlet does not return a status code, a successful status code of HTTPSERVLETRESPONSE.SC_OK is returned by default.
HTTP headers (HTTP header): They contain more information about the response. For example, the header can specify an expiration date that the response expires, or an encoding format that specifies the content of the transport entity that is used to secure the user. How to retrieve HTTP headers in Serlet look here.
Body: It contains the contents of the response. It can contain HTML code, pictures, and so on. A principal is made up of data bytes that are transmitted immediately behind the head in an HTTP message.

2. What is a cookie? What is the difference between a session and a cookie?

A cookie is a piece of information that a Web server sends to a browser. The browser stores cookies for each Web server in a local file. Later, when the browser sends a request to a particular Web server, all cookies stored for that server are sent at the same time. The differences between session and Cookie are listed below:
No matter what the client browser does, the session should work correctly. The client can choose to disable cookies, but the session still works because the client cannot disable the session on the server.
The session and the cookie are not the same in terms of the amount of data stored. Session can store arbitrary Java objects, and cookies can only store objects of type string.

3. What protocol is used for browser and servlet communication?

The browser and servlet communication use the HTTP protocol.

4. What is an HTTP tunnel?

HTTP tunneling is a technology that uses HTTP or HTTPS to encapsulate multiple network protocols for communication. Therefore, the HTTP protocol plays the role of a wrapper through the pipeline for communicating network protocols. The request to mask requests for other protocols as HTTP is the HTTP tunnel.

What is the difference between the 5.sendRedirect () and Forward () methods?

The Sendredirect () method creates a new request, and the forward () method simply forwards the request to a new target. After redirection (redirect), objects that were within the scope of the previous request are invalidated because a new request is generated, and after forwarding (forwarding), objects within the scope range of the previous request can be accessed. Sendredirect () is generally considered to be slower than forward ().

6. What is URL encoding and URL decoding?

URL encoding is responsible for the space inside the URL and other special characters to replace the corresponding hexadecimal representation, the reverse is decoding.

Interview questions-java web-network communication

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.