views:

316

answers:

2

How can I pass a variable from JSF managed bean to JSP page.

PS: I'm in portal context (liferay).

I tried this:

in Managed Bean:

HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

request.setAttribute("var", "someTxt");

in JSP:

<% 
    String var = (String)request.getAttribute("var");
%> 

I don't get any result.

+1  A: 

You have to stay in the same request - i.e. forward, instead of redirect to the jsp.

If this is not possible you may use the session instead of the request, but be careful with storing too much information there.

Bozho
A: 

You may try to wrap your scriptlet code with JSF tag.

Alexander Prudnikov

related questions