File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "the lifespan of a request?" Watch "the lifespan of a request?" New topic

the lifespan of a request?

Per Jorgen Walstrom

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

I call 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/ 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 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!

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

Joined: Jul 06, 2005
Posts: 1580
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"/>

- put the attribute in session
- don't redirect on a "listChannels" request
I agree. Here's the link:
subject: the lifespan of a request?
jQuery in Action, 3rd edition