SERVLET&JSP Study Notes

Source: Internet
Author: User

<title>SERVLET&JSP Study Notes</title> SERVLET&AMP;JSP Study notes Table of Contents
    • 1 Web Container
    • 2 Built-in objects
      • 2.1 Built-in object categories
        • 2.1.1 Out
        • 2.1.2 Request
        • 2.1.3 Application
        • 2.1.4 Response
        • 2.1.5 Session
        • 2.1.6 Other
    • 3 JavaBean
      • 3.1 JSP action elements
      • Four effects of 3.2 JavaBean on the range
    • 4 JSP State Management
      • 4.1 Cookies
      • 4.2 The difference between include directives and actions
1Web container2Built-in objects

A JSP built-in object is a set of objects created by the Web container, and built-in objects that you can use without using the New keyword.

2.1Built-in object classification2.1.1Out

An instance of the JspWriter class that outputs common objects to the client.

2.1.2Request
    • Get and post get data submitted in clear text via URL, suitable for data with small data volume and low security

      Post encapsulates user-submitted information in the HTML header, which is suitable for data with large data volumes and high security.

    • Request represents a single request from the client. The client's requests are encapsulated in the requestor object. is an instance of the HttpServletRequest class. Request has a requesting domain and is valid until the user completes the request
2.1.3Application

The Application object realizes the sharing of data among users and holds the global variables. Start with server start, terminate with server shutdown. Is an instance of the ServletContext class.

2.1.4Response

is an instance of the HttpServletResponse class that contains the information that responds to a customer request. With pages acting on. That is, accessing a page is that the response object within the page is valid only for this access, and the response object on the other page is not valid for the current page.

    • Request redirection and request forwarding redirection is a client-side behavior that is equivalent to two requests, the previous request object will not be saved, and the address bar's URL address will change. Response.sendredirect ();

      Forwarding is the server should be, is a request, after forwarding the request object will be saved, the Address bar URL address will not change. Request.getrequestdispatcher (). Forward (Req,res);

2.1.5Session

Session represents a client-to-server conversation. is actually a time concept.

stored in the server's memory, save the session of the different users

Set the session timeout time. 1) Session.setmaxinactival (time) 2) configure in Web. xml

2.1.6Other

Page, PageContext, exception, config

3JavaBean

JavaBeans a Java class that conforms to a particular specification.

JavaBean's design principles:

    • Common class
    • Property Private
    • method of constructing without parameters
    • Getter and Setter methods
3.1JSP action elements
    • Related to access to JavaBean
    • The basic elements of JSP1.2
    • JSP2.0 started new with JSP Docuement
    • Dynamically generate values for XML element labels
    • The action used in the tag file
3.2Four effects of JavaBean on the range
    • Page//is valid only on the current page
    • Request//Can get JavaBean object by Httprequest.getattribute () method
    • session//Can get JavaBean object by Httpsession.getattribute () method
    • application//Can get JavaBean object by Application.getattribute () method
4JSP State Management
    • Session
    • Cookies
4.1Cookies

A series of text messages that the Web server holds on the client

    • Session vs. Cookie
      • All the mechanisms that hold customer data have expiration periods.
      • Session is a server-side save user information cookie is a client saving user information
      • The session holds an object type cookie that holds a string type
      • The session will destroy the cookie as it ends and can be stored on the client for a long time.
      • Session General preservation of important information cookies generally keep unimportant information
4.2The difference between the include directive and the action
    • Syntax format
      • directive: <%@ include%> action: <jsp:include page= "" >
      • An instruction occurs during a page transition during a request
      • The instruction contains the actual contents of the file, including the output of the page.
      • instruction when the master page and the containing page are converted to a servlet action, they are converted to two servlets respectively
      • Instruction quality compilation slow execution faster fast action compilation slower

Date:2015-01-24

Author:chenjingran

ORG version 7.8.11 with Emacs version 24

Validate XHTML 1.0

SERVLET&JSP Study 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.