This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 4442
    
    5

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
 
wood burning stoves
 
subject: Couldn't access bean:define variable in action class using request.getAttribute
 
Similar Threads
problem in getting data from request
Html:link forward +parameter passing
NullValueInNestedPathException for Bean class binding
how to access a bean that has bean created by <jsp:useBean> tag?
Problems with jsp:include