struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: to forward or NOT?
Date Mon, 02 Jun 2003 03:38:45 GMT
<snip>
I am assuming that the only reason
that the Response is in the Action.execute signature is for
setting/retrieving cookies.  The best solution would be for the Action to
forward to a Servlet that would send the resource to the client.
</snip>

Not necessarily. It rather depends what the action is doing. Having actions
that return a file for download is quite reasonable. By putting this code in
the action you have access to all the struts stuff like the mapping and the
struts exception handling, which you may well wish to take advantage of.

In this case he might not be sending a file, it looks like he just wishes to
update something in his business layer when he receives a certain request,
doing it as a one-way request with no response. Of course all requests do
have a response, but if memory serves me (I may well be wrong) there is an
HTTP response code for this situation. (I forget which number), so perhaps
he could have the action do its thing and write a response with that code.
Havent tried it myself but its worth a shot.

You can return null in the Action if you dont want to forward, however this
in itself wont prevent a response being sent to the client. It merely
signifies to struts that you have written the response page in your action.
If you dont actually write anything, I would think you would still be
sending a response , but it would be an empty one.

-----Original Message-----
From: James Norman [mailto:jnorman@taregon.com]
Sent: Monday, 2 June 2003 05:25
To: Struts Users Mailing List
Subject: Re: to forward or NOT?


>>From what I understand about the question, it sounds like the user is
downloading a file from the server and you want to abort the request after
the action executes.  It also sounds like the download is taking place in
the Action.  What I don't understand is how the users web page could be
changed after the download is complete.  Any HTML that is sent would then be
in the download stream.  A redirect may change the web page after the
download however that is not likely.  In either case I think that there is a
issue in the way that you are using an Action.  The executing Action should
not be sending anything to the Response.  I am assuming that the only reason
that the Response is in the Action.execute signature is for
setting/retrieving cookies.  The best solution would be for the Action to
forward to a Servlet that would send the resource to the client.

-james

----- Original Message -----
From: "David M. Karr" <dmkarr@earthlink.net>
To: <struts-user@jakarta.apache.org>
Sent: Sunday, June 01, 2003 12:11 AM
Subject: Re: to forward or NOT?


> >>>>> "Riyaz" == Riyaz Mansoor <rmanchu@yahoo.com> writes:
>
>     Riyaz> hi
>
>     Riyaz> is it at all possible to NOT forward after executing an action?
>
>     Riyaz> here's my situation. a link would execute a download action and
the file
>     Riyaz> downloads fine. however, i want to keep the existing webpage
displayed and
>     Riyaz> NOT move to a different page.
>
>     Riyaz> is there a ActionForward directive or other that tells struts
to stay put?
>
>     Riyaz> OR would i have to construct the full url (with parameter
name/values) and
>     Riyaz> forward there?
>
>     Riyaz> ideas?
>
> Did you try returning null from the Action method?
>
> --
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
> dmkarr@earthlink.net   ; SCJP; SCWCD
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message