Java Web Foundation

Source: Internet
Author: User

1. HTTP protocol:

FTP protocol:

2. Request Protocol Format:

Request Line

Multiple Request header information: Header Name Header value

Blank Line

Request body (GET request without request body)

Introduction to the request header:

Content-type Set URL encoding
Content-length

Request protocol is the length of the request body, response length in response

It's the right length anyway.

Refer

1 Statistical access sources

2 Anti-theft chain

Refresh Timed jump
Expires:-1 Expiry time
Cache-control:no-cache

Compatible with the next version of the HTTP protocol

Disable browser caching with adjacent two-bar settings

Prama:no-cache

3 Response protocol:

Response Header (interpretation of Protocol/version Status Code status code) 2 start successfully; 3 start forwarding; 4 opening client problem; 5 opening service-side issue

Multiple Request header Information Header Name header value

Blank Line

Response body

302 redirect
304

Valid only for static content, with cache

For the purpose of saving the transmission cost setting

4 URL encoding for transmission of Chinese characters

Number of bytes in the first step +128

The second step turns into 16 binary

Step three before 16 binary + on "%"

5 Servlet

A each servlet is unique, and the requests they handle are different.

b In a servlet, you can usually:

1 Receiving Request data

2 Processing Requests

3 Complete the corresponding

C Three ways to implement a servlet

1 implementation of Javax.servlet.Servlet (with 4 methods)

2 Inheriting Javax.servlet.GenericServlet (one method)

3 Inheritance Javax.servlet.Http.Httpservlet (servlet related to Http protocol)

    

Most methods in the D servlet have server invocation, creation, etc.

E servlet features: non-thread-safe, relatively high efficiency of the device

F Precautions:

1 Try not to create members in the servlet

2 You can create stateless members

3 You can create a stateful member, but the state must be read-only

G Initial order of exchange:

Reflection in the H servlet: the server invokes the servlet and its methods with reflection

I have only one ServletContext object in a project, we can get this unique object in n Servlets, use it to pass data in multiple servlet parameters , ServletContext the same as the lifetime of the project

J Domain Objects: (4)

1 PageContext

2 ServletRequest

3 HttpSession

4 ServletContext

Domain objects have a map to access the data

K ServletContext Get initialization parameters

      Note: The parameters obtained with the servlet are not one, because the domain is different, you can configure common initialization parameters, share for all servlets, use ServletContext to obtain the use of HttpServlet

//       Real server-side file address         Getservletcontext (). Getrealpath ("/index.jsp"); //         get the URL stream        getservletcontext (). getResourceAsStream ("/index.jsp"); //         get the URL address        getservletcontext (). GetResource ("/index.jsp");

L Get resources under the Classpath

You can use the K method

      

Java Web Foundation

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.