I have a servlet that will navigate to a JSF page upon some conditions using ExternalContext.redirect. I need to initialise a Managed Bean in this Servlet and set it in request scope so that my JSF page can directly access the Managed Bean's property and display them on the page load.
I had seen posts that sets the bean using getServletContext()
Like,
getServletContext().setAttribute("beanName",new Bean())
it works.But this approach will be setting the bean in application scope instead of request scope.
Also i tried the following:
request.setAttribute("beanName",new Bean())
it doesnt work
So pls let me know if there is any way to set /initialise a managed bean in a request scope
@RequestScope
and access it from your page? – LaurentG@ViewScoped
annotation. The bean will be created since user access to the view (this will be in the redirection) and will live until the user leaves the view (change to another view, closes the tab or closes the browser). – Luiggi Mendoza