The difference between the session of the JSP and the session of the servlet

Source: Internet
Author: User

1. Session mechanism
HTTP is a stateless protocol, each time a client reads a Web page, the server opens a new session, and the server does not automatically maintain the client's contextual information, the session is a mechanism to save context information, it is for each user, the value of the variable is stored on the server side, By SessionID to differentiate between clients, the session is based on cookie or URL rewriting, which is implemented by default using cookies, and the system creates an output named Jsessionid that is returned to the client cookie to be saved.

2. The relationship between JSP and servlet
JSP is a simplification of servlet, JSP is the extension of servlet technology, is essentially the simple way of servlet. The JSP is compiled with a "class servlet". The main difference between Servlets and JSPs is that the application logic of the servlet is in the Java file and is completely detached from the HTML in the presentation layer. The case for JSP is that Java and HTML can be combined into a file with a. jsp extension. JSPs focus on views, and Servlets are used primarily for control logic .

The session of the JSP and the session of the servlet are essentially consistent, the difference is that the session in the JSP as an implicit object exists, can be used directly; the session in the servlet needs to be extracted manually before being used.
HttpSession is the Java platform for the implementation of the session mechanism specification, because it is only an interface, specific to each Web application Server provider, in addition to the specification support, there will still be some specifications do not specify the subtle differences.

Salute (programming Idea)!

The difference between the session of the JSP and the session of the servlet

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.