Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sandeep Ghosh
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sandeep Ghosh
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic