Dashboard > WebWork 1 > WebWork CookBook > How to add retrieve from HttpSession
  WebWork 1 Log In View a printable version of the current page.  
  How to add retrieve from HttpSession
Added by Andre Mermegas, last edited by Hani Suleiman on Apr 25, 2004  (view change)
Labels: 
(None)

Here is how you can add/retrieve from session:

If you want to add an attribute to the session in your Action
you can do so as follows

package webwork.blank.actions;

import webwork.action.ActionSupport;
import webwork.action.ServletActionContext;

public class MyAction extends ActionSupport
{
    public String doExecute() throws Exception
    {
        //example: add something to the session.
        String name = "Andre Mermegas";
        ActionContext.getSession().put("name",name);
        return SUCCESS;
    }
}

Now to access this or any session attribute from the view, in this case a JSP

<%@ taglib uri="webwork" prefix="ww" %>
<html>
<ww:property value="@name" />
</html>

You can also perform methods on the attributes if they have them

<%@ taglib uri="webwork" prefix="ww" %>
<html>
<ww:property value="@name/toUpperCase" />
</html>

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators