• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing Parameters from Bean to JSP Page

 
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic