The moose likes JSF and the fly likes Passing Parameters from Bean to JSP Page Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Passing Parameters from Bean to JSP Page" Watch "Passing Parameters from Bean to JSP Page" New topic
Author

Passing Parameters from Bean to JSP Page

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 493
I am trying to put a String inside of a request object which is contained in my Managed bean. So that I can retrieve it in my JSP using the
request object, but its kind of failing

This is the code in my Managed Bean


getFacesContext().getExternalContext().getRequestMap().put("display","Hello");


and in my JSp i have

String tempString=(String)request.getAttribute("display");


Any suggestion would be welcome
Praful Sinha
Greenhorn

Joined: Jan 25, 2008
Posts: 18
Hi Adisa,

Hi
Istead of getRequestMap method please use getRequest.
Which will give you request object of your Http protocall.

Please use this code and try to fetch your string value in jsp.

HttpServletRequest req=(HttpServletRequest)getFacesContext().getExternalContext().getRequest();
req.setAttribute("display","Hello");



and in my JSp use
String tempString=(String)request.getAttribute("display");

Thanks and Regards,
Praful Sinha
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1790
code looks OK. may be some other problem like you are making multiple requests.


Krishna Srinivasan
Java Writers Needed
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 493
Originally posted by Praful Sinha:
Hi Adisa,

Hi
Istead of getRequestMap method please use getRequest.
Which will give you request object of your Http protocall.

Please use this code and try to fetch your string value in jsp.

HttpServletRequest req=(HttpServletRequest)getFacesContext().getExternalContext().getRequest();
req.setAttribute("display","Hello");



and in my JSp use
String tempString=(String)request.getAttribute("display");

Thanks and Regards,
Praful Sinha


Thanks for the reply it worked
 
 
subject: Passing Parameters from Bean to JSP Page
 
Threads others viewed
How do I set this managed bean property?
Providing anchor to columns in a datatable
what methods do managed bean and backing bean contain
jsf problem go from jsp page to another jsp in new window
JSF validator problem
MyEclipse, The Clear Choice