Excerpt from: "Lightweight Java EE Enterprise Application" Third edition
For each client request, the Web server roughly needs to complete the following steps:
1. Start a separate thread
2. Use I/O stream to read the user's request parameters
3. Parsing parameters from the request data
4. Handling User Requests
5. Generate Response Data
6. Send request data using I/O flow to the client
1, 2, 6 is universal, by the Web server completed, 3, 4, 5 There are differences, because different requests contain the request parameters are different, the way the user requests are processed differently, the resulting response is different, this 3 step is done by the servlet's _jspservice () method. When writing a JSP page, the static content of the page, the JSP script will be converted to the _jspservice () method execution Code (note: JSP Java declaration, that is, <%! ...%> is a member variable and member method after the JSP is converted to a servlet, not in the _jspservice () method, which is responsible for parsing parameters, processing requests, generating responses, and so on, while the Web server completes the underlying functions of multithreading, network communication, and so on.
Exchanging data between JSP Servlets (personally feel that the servlet here should not be the servlet that was generated after the JSP was compiled)
Application Session Request page
Application: Valid for the entire Web application, once the JSP, Servlet puts the data into session, the data will be used by all other JSPs, servlet access
Session: Only valid for a single reply, once the JSP, servlet data into the session, the data will be all the other JSP, servlet access
Request: Valid only for this time, once the JSP, Servlet puts the data into request, the data will be accessed by other JSPs, servlet
Page: Valid only for the current page, once the JSP, Servlet puts the data into the page, the data can only be accessed by the JSP script, the declaration part of the current page
Sessions should typically only store information that is relevant to the user's session state. If you are simply exchanging information for two pages, you can store that information in the request and then forward it.