Portlet Factory, Version 6.1.2


 

Interacting with the session object

You can store objects in the session by setting attributes on the session and specifying the value for those attributes as the objects that you want to share between models.

Storing objects in session

For example, if you wanted to share the value of a variable, companyname, with another model, you would use code similar to the following:
webAppAccess.getHttpServletRequest().getSession().put("companyname", webAppAccess.getVariables().getText("companyname"));

Retrieving objects from the session

To get objects out of the session for use in the current model, call the get method on the Session object. For example, to retrieve the company name stored by the code in the "Storing Objects in Session" section, implement code similar to the following:
String companyName = webAppAccess.getHttpServletRequest().getSession().get("companyname");

Removing objects from the session

To remove objects from the session, call the remove method on the Session object. For example, to remove the company_name session attribute created by the code in the "Storing Objects in Session" section, implement code similar to the following:
webAppAccess.getHttpServletRequest().getSession().remove("companyname");

Parent topic: Overview: working with Java


Library | Support |