aspose file tools*
The moose likes Struts and the fly likes Couldn't access bean:define variable in action class using request.getAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Couldn Watch "Couldn New topic
Author

Couldn't access bean:define variable in action class using request.getAttribute

Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
Hi Friends,
I am trying to forward a bean object from my JSP page to my Action class. I am using this statement for this purpose
<bean efine id="nextpage" name="pagewise" scope="request" toScope="request" type="PagewiseBrowseForm " />
In my action class
PagewiseBrowseForm pageForm=(PagewiseBrowseForm)request.getAttribute("nextpage");
But value of pageForm is null.
Any help is always gratefully received.
Thanks in adv.
Sonu
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4456
    
    6

request-scope attributes exist only while a request is being processed on the server side. In the JSP, the attributes are available only while the page is being rendered. Once the page gets rendered and the response goes out to the client, the attributes disappear (since your request has gone out of scope, it's attributes go out of scope as well).
You might want to keep your attribute in the session scope instead although I'm not sure I understand why you want to play around with a Form bean since the Struts framework already manages them in the session scope anyway. Besides, the form is always passed to your Actions execute()/perform() method so there's hardly ever any reason to do what it looks like you're trying to do.


Junilu - [How to Ask Questions] [How to Answer Questions]
Sandeep Ghosh
Ranch Hand

Joined: Jan 23, 2002
Posts: 145
I was trying to do show resultset page wise. For this I have a bean where I kept resultset info like total records,last records seen etc .When I put this object in session bean I was running into problem.So I was trying to keep that in request scope. Now I have kept constant infos like resultset size in session and some info like last record fetched as request parameter.
Does anybody have any better idea for pagination in struts as I don't want to bring complete resultset in one trip.
Sonu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Couldn't access bean:define variable in action class using request.getAttribute