Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

You can use ServletContexts.instance().getRequest() in your backing bean.

Another approach is to define a factory in your component descriptor so that you can inject the HttpServletRequest or HttpSession directly into your Seam component. (Note, the default scope for a factory is event).

<factory name="httpRequest"
  value="#{facesContext.externalContext.request}"
  auto-create="true"/>
<factory name="httpSession"
  value="#{facesContext.externalContext.request.session}"
  auto-create="true"/>

@In HttpServletRequest httpRequest;
@In HttpSession httpSession;

You could also use the servletContexts component in the factory.

The only downside with the factory solution is that the casts to HttpServletRequest and HttpSession are masked (you are just assuming that is what they are).

If you intent on terminating the session, you should be using Seam's HttpSession facade, webSession, an alias for org.jboss.seam.web.session.

@In Session webSession;

...
webSession.invalidate();

or

#{webSession.invalidate}

It is illegal to call invalidate on the HttpSession directly when Seam contexts are active.