This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes get/set attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "get/set attribute" Watch "get/set attribute" New topic
Author

get/set attribute

Rang Sar
Greenhorn

Joined: Jan 28, 2006
Posts: 4
Hi,

I have a Action class and it forwards to a jsp. I set a Object in request scopt and obtain it in jsp and again set it to request scope. Now in jsp i have a button, when clicked this goes to another Action Class. I am not able to get the object from request. it is always null.

-Rang
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

"Ranga S",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Originally posted by Ranga S:

I have a Action class and it forwards to a jsp. I set a Object in request scopt and obtain it in jsp and again set it to request scope. Now in jsp i have a button, when clicked this goes to another Action Class. I am not able to get the object from request. it is always null.


That is correct. The request goes out of scope when the response is returned to the client.

I suggest reading this article for a better understanding of the life-cycle of a JSP request.
Rang Sar
Greenhorn

Joined: Jan 28, 2006
Posts: 4
Can you please tell me is there any solution to this ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

"Ranga S", my request that you adjust your display name was not a suggestion. Valid display names are a requirement for participation on the JavaRanch. Please re-read my request and change your display name prior to your next post.

bear
JavaRanch Sheriff
[ January 28, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Thank you.

To persist a scoped variable across multiple requests, one means is to place the scoped variable into session scope rather than request scope.

When doing so, take care to "clean up" after yourself as sessions only go out of scope when they timeout, so you may end up with a lot of wasted memory if you aren't careful with session data.
Rang Sar
Greenhorn

Joined: Jan 28, 2006
Posts: 4
Thanks for your reply.
Without putting to session is there any way where I can manage with requests only ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

You could propogate the values by writing them as hidden elements in the page's form so that they will be re-submitted on the next request.

That's more work and means everything needs to be serialized to string values.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get/set attribute
 
Similar Threads
get/set attribute
Problem in setting Application scope Object
why i cannot get request object in Action class from jsp
problem with registration page
4 fields that makes one set