You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sudip shrestha <su...@gmail.com> on 2005/11/09 18:02:48 UTC

Can one Action Method POST to another?

I have situation here where one action method need to do a POST to another
method of a DispatchAction implementing class. I need to know if this is
possible.
I have a struts webapp that uploads file to a ftp web server and so one of
the POST variables is a Struts "FormFile" object. If it were just string
parameters, I could do away with a GET.
The idea here is to display a "Please Wait" type of intermediate page before
the first action forwards with all the POST variables to a second action
method....
Thanks for any inputs....

Re: Can one Action Method POST to another?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 11/9/05, Michael Jouravlev <jm...@gmail.com> wrote:
> On 11/9/05, sudip shrestha <su...@gmail.com> wrote:
> > I have situation here where one action method need to do a POST to another
> > method of a DispatchAction implementing class. I need to know if this is
> > possible.
>
> Redirect with 307 code. HttpResponse.sendRedirect() sets response
> header to 302 by default and you cannot change header after response
> was written, so you need to forge response with proper header
> yourself.
>
> Most modern browsers understand 307 response, it is defined in HTTP
> 1.1 spec (1999, baby!)
>
> See details here: http://ppewww.ph.gla.ac.uk/%7Eflavell/www/post-redirect.html

Oops, will not work. I forgot that 307 requires user's confirmation.
Sorry that I misled you.

Michael.

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


Re: Can one Action Method POST to another?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 11/9/05, sudip shrestha <su...@gmail.com> wrote:
> I have situation here where one action method need to do a POST to another
> method of a DispatchAction implementing class. I need to know if this is
> possible.

Redirect with 307 code. HttpResponse.sendRedirect() sets response
header to 302 by default and you cannot change header after response
was written, so you need to forge response with proper header
yourself.

Most modern browsers understand 307 response, it is defined in HTTP
1.1 spec (1999, baby!)

See details here: http://ppewww.ph.gla.ac.uk/%7Eflavell/www/post-redirect.html

Michael.

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


Re: Can one Action Method POST to another?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I'm not completely sure I understand your question, but if your simply
asking if one Action call forward to another, the answer is yes.  This is
commonly referred to as "Action Chaining".  If it's a forward, you'll be
using the same request object, so anything in there will be present for
the second Action.  If it's a redirect, that won't be true.  One Action
can also directly call methods on another if you wish, it's just a normal
class.

If what you mean is can you do a POST to a URL (which might just happen to
be to an Action in the same webapp) from an Action, the answer isn't
Struts-specific... it's just some network coding as you might normally do
from a simple Java app.  I'd suggest looking at the Commons packages to do
this, it will save you time and trouble, but in the end it's simply
spawning a new request from within an Action, waiting for a response and
doing something with it.

As for a Please Wait display, have a look at the Wiki, there is an entry
for doing that which looked rather interesting.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Wed, November 9, 2005 12:02 pm, sudip shrestha said:
> I have situation here where one action method need to do a POST to another
> method of a DispatchAction implementing class. I need to know if this is
> possible.
> I have a struts webapp that uploads file to a ftp web server and so one of
> the POST variables is a Struts "FormFile" object. If it were just string
> parameters, I could do away with a GET.
> The idea here is to display a "Please Wait" type of intermediate page
> before
> the first action forwards with all the POST variables to a second action
> method....
> Thanks for any inputs....
>


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