File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes the lifespan of a request? 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 "the lifespan of a request?" Watch "the lifespan of a request?" New topic
Author

the lifespan of a request?

Per Jorgen Walstrom
Greenhorn

Joined: Apr 28, 2005
Posts: 6
hello,
I have the following actions


I call listDocuments.do and the resulting jsp-page lists some "channels" where it is possible to delete a chosen channel, by following a link to http://localhost:8080/saveChannel.do?method=delete&id=40278. ChannelAction extends DispatchAction. Now, in ChannelAction, I do a check if the channel can be deleted. If not, I do the following:



The thing is now, that listChannels.do does not seem to be able to display the errors. The attribute is gone from the request. Why is this? I have only done one request, as far as I can see. Does Struts consider going to another Action to be a completely new request?

any help would be appreciated!

cheers,
pj
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Request is valid only for request time. If you want have data longer use another scope - session for example. I'm not sure how struts handle with request, but it is possible that after forward it creates new request.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Request attributes last for the scope of a request.
Forward/include happens on the same request.
A redirect sends a response telling the browser to send a new request.

So request attributes are retained over a forward/include
Request attributes are lost if you issue a redirect.

Looking at your actionforward for /listChannels:
<forward name="forward" redirect="true" path="/channellist.jsp"/>

Solutions
- put the attribute in session
- don't redirect on a "listChannels" request
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the lifespan of a request?