How to pass variable from jsf managed bean to jsp page
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.
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.
You may try to wrap your scriptlet code with JSF tag.
精彩评论