开发者

How to pass variable from jsf managed bean to jsp page

开发者 https://www.devze.com 2022-12-28 06:55 出处:网络
How can I pass a variable from JSF managed bean to JSP page. PS: I\'m in portal context (liferay). I tried this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消