Open-source portal implementation-liferay's Portlet session processing (1)

Source: Internet
Author: User

1. Session Description in the Specification

(Portletsession objects must be scoped at the Portlet application context level. each Portlet application has its own distinct portletsession object per user session. the Portlet container must not share the portletsession object or the attributes stored in it among different Portlet applications or among different user sessions .)
The above section is a section in the Portlet specification. Clearly, we can see that each Portlet application should have its own private session object during process action and render to serve the current user. That is to say, if a user operates different Portlet in a portal system and these Portlet belongs to different Portlet applications, the user operates multiple session objects, when you operate a session in each Portlet, this session will be a private session object in the context of the Portlet. For example, a user's current page has three Portlet, each of which belongs to a different Portlet application. When the user has a session operation in the first Portlet, the application to which the Portlet belongs will generate a session for the user; when the user operates the session in the second Portlet, the context generates a new session object for the user. In addition, the session of the portal system means that the user is actually dealing with four sessions.

The relationship between the Portlet application and the web application is also worth noting. The specification has the following definitions:
(Portlets, servlets and JSPs are bundled in an extended web application called Portlet application. portlets, servlets and JSPs within the same Portlet application Share Class Loader, application context and session .)
This shows that the Portlet application is actually a web application. This problem is explained in another section in the specification, and the relationship between the Portlet session and the session of the common application is also emphasized:
(A Portlet application is also a web application. the Portlet application may contain in servlets and JSPs in addition to portlets. portlets, servlets and JSPs may share information through their session. the portletsession must store all attributes in the httpsession of the Portlet application. A direct consequence of this is that data stored in the httpsession by servlets or JSPs is accessible to portlets through the portletsession In the Portlet application scope. conversely, data stored by portlets in the portletsession In the Portlet application scope is accessible to servlets and JSPs through the httpsession. if the httpsession object is invalidated, the portletsession object must also be invalidated by the Portlet container. if the portletsession object is invalidated by A Portlet, the Portlet container must invalidate the associated httpsession object .)

The last point is how to obtain the Portlet session object. There is an example in the Specification:
Portletsession session = request. getsession (true );
URL url = new URL (http://www.foo.com);
Session. setattribute ("home. url", URL, portletsession. application_scope );
Session. setattribute ("BKG. Color", "Red", portletsession. portlet_scope );

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.