Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Parameters from Bean to JSP Page

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1874
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code looks OK. may be some other problem like you are making multiple requests.
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic