Web session and other scopes

A web session is a permanent memory that starts when a web URL is called by the browser and usually ends after the closing of the browser. The life of a web session is tied to the user. The web session provides two important operations:

  • Activation: It is activated when the session starts, by default, when a user connects to the web application for the first time. This operation can be forced, thanks to the activate method of the web session.
  • Passivation: It is triggered when the session ends, by default, when a user closes the browser. This passivate can be forced, thanks to the activate method of the web session.

The web session is represented by the javax.servlet.http.HttpSession interface.
In addition to the web session, three important scopes exist in the web:

  • Request scope: It ends after the first call to a web URL. After the call, all information parameters will be loose. It provides good performances but less registered information.
  • Page scope: It collects the information present inside a web page, and is used only in JSP.
  • Application scope: All information is in memory for the complete duration of the web application. By duration, we mean the time after the deployment of the application until the undeploy. It's more persistent but more expensive at the performance level.

Now, let's continue with the analysis of the servlet. The next step is to create a cookie.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.130.24