File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes put request.Property value into bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "put request.Property value into bean" Watch "put request.Property value into bean" New topic

put request.Property value into bean

dibs dibley

Joined: Aug 31, 2003
Posts: 13
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?
Eelco den Heijer
Ranch Hand

Joined: Jan 17, 2002
Posts: 61
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.

== <br />Rgrds,<br />Eelco<br /> <br />SCJP, SCJD, SCBCD, SCWD, SCEA
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
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

Joined: Aug 31, 2003
Posts: 13
Thats it!

I agree. Here's the link:
subject: put request.Property value into bean
It's not a secret anymore!