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