How do I access Request or Session from Seam?

Two ways :
1) Easy way: use ServletContexts.instance().getRequest() in your backing bean.

2) Define a factory in your component descriptor and inject the HttpServletRequest or HttpSession directly into your Seam component.

<factory name="httpRequest"
<factory name="httpSession"

@In HttpServletRequest httpRequest;
@In HttpSession httpSession;

If on the other hand you don’t need the HttpRequest but only the request parameters, simply use the  @RequestParameter(“parameterName”) annotation which inject into your component the value of a request parameter

Found the article helpful? if so please follow us on Socials