jQuery in Action, 2nd edition*
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
Author

put request.Property value into bean

dibs dibley
Greenhorn

Joined: Aug 31, 2003
Posts: 13
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

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
Greenhorn

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

Cheers
 
 
subject: put request.Property value into bean
 
Similar Threads
Calling a URL via HttpClient
ejbCreate with generated column contents
Getting values from form bean into javascript function
JSP beans and JRun
Value Binding at runtime