cancel
Showing results for 
Search instead for 
Did you mean: 

Reading session variables from inside an Alfresco extension

patorjk
Champ in-the-making
Champ in-the-making
I have a filter setup where I set a session variable like so:

HttpSession session = httpServletRequest.getSession();
session.setAttribute("myLastName", "some last name");

How would I access this value inside of an extension that I write? I tried:

String lastName = (String) RequestContextHolder.currentRequestAttributes().getAttribute("myLastName", RequestAttributes.SCOPE_SESSION);

But I get the following error thrown when that line is executed:

No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Does anyone know how to access session variables created inside of filters?

thanks,
1 REPLY 1

patorjk
Champ in-the-making
Champ in-the-making
It appears adding the following code to my web.xml file allows the code in my previous post to work:

<listener>
     <description>Spring Framework Initilization</description>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>

I figured I'd post it in case anyone runs into the same issue.