• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

put request.Property value into bean

 
dibs dibley
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This may be simple but...
I have a value passed to a servlet via a get i.e. ?item=value
I retrieve this value with request.getProperty(value);
but i want to put the value into a bean so as serveral other jsp's and servlets can retrieve it from that bean.
How do i do it?
Cheers
 
Eelco den Heijer
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For passing objects in request scope:
Object item = request.getAttribute("item");\
item = new Object("bla");
request.setAttribute( "item", item);
Session scope:
HttpSession session = request.getSession( true );
Object item = session.getAttribute("item");
item = new Object("bla");
session.setAttribute( "item", item);
There is also an servlet context wide scope if the
former two are not enough.
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the bean hasn't bean created, and you want it in the session scope:

I think that this is what you're looking for
 
dibs dibley
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Thats it!

Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic