JAVA Web Notes

Source: Internet
Author: User

A good memory is better than a written one.

Tool class: JUNIT4 using MyEclipse shortcut key Tomcat Project deployment method

Knowledge Point: HTTP protocol detailed HTTP protocol in-depth servlet details

Javase Tutorial Java5 new features JAVA6 new features Java7 new features JAVA8 new features

First, servlet/jsp Overview:

1, the HTTP header is useful, the servlet accepts the HTTP protocol modified by the request, request and HTTP-related information can be processed by the servlet, of course, the corresponding content and HTTP processing.

2, the servlet can be preprocessed do not forget, before the Init method executes, that is, when the server starts, the browser does not access pre-processing something.

3. For Servlets, remember the word: Requests made from the client (http+ requests) can be accepted and responded to by the servlet, and the request information is usually stored and fetched in a shared container (ServletContext).

4, from the request to the access server this process has a lot of things to deal with: preprocessing, encapsulation information ... ; We know that JSP is a servlet-based, JSP has built-in objects (out/request/response/session/pagecontext/application/config/page/exception), It is obvious that the instances of these built-in objects are generated by the server, both in the access (client) <----> Response (server) process.

5. Servlet interface->genericservlet Subclass->httpservlet grandson Class

 6, a servlet is a Java class that runs on the server side, is actually a class that the server is getting through reflection, because the class is obtained by using reflection, so the class name must be given ( Configured in Web. XML, the server obtains the class name by parsing the file, reflects the class, invokes its method, and the client makes the request, which is sent in the HTTP protocol, so the server must be able to parse the HTTP and encapsulated information, in order to better facilitate the transfer of information, The server implements a series of "small functions" according to the Servlet protocol, servletcontext/includes the built-in objects of the JSP, and uses these "small functions", different functions to handle different content, for example: response is responsible for encapsulating the detailed response content (including HTTP-related), The information passed by the client is handled by Request encapsulation (including HTTP-related), global container servletcontext; it Yes Get Web Global initialization parameters, data sharing, access to resource files : Because our program is placed on the server, usually we do not care about the path of resources such as files, but we have to manipulate the file, no path how to deal with, ServletContext provides two ways:  

         Properties  New  properties ();         // this uses getResourceAsStream to read the file        Pro.load (Getservletcontext (). getResourceAsStream ("/web-inf/classes/db.properties"));                         // the traditional input stream used here reads the file, and first requires the ServletContext object to get the real file path.        Pro.load (new FileInputStream (Getservletcontext () Getrealpath ("/web-inf/classes/db.properties"));

These encapsulation procedures are automatically completed by the server according to the servlet protocol, and finally we only need to take these packaged built-in objects to use;

Second, Servlet:response, request

Stay......

Third, Jsp:cookie session

JAVA Web Notes

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.