You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by enthucoder <re...@yahoo.com> on 2008/01/22 16:56:59 UTC

Re: [S1] Best practice to transfer control to next page (out of JVM)?

Can  you give some pointers on how do i contruct a HTTP POST Message in my
Action and redirect the page to remote resource (non J2EE App)..?


Laurie Harper wrote:
> 
> enthucoder wrote:
>> Hi,
>> 
>> Please bear with me, incase this turns out to be a dumb question.
>> 
>> I want to transfer control to a non JSP page after I hit submit. Apart
>> from
>> this I am also sending some data as a HTTPS POST. In case of using
>> response.sendRedirect(), it doesn't take care of the POST data.
>> 
>> So, can anybody help me with what's the best practice in sending POST
>> request from a Struts based J2EE application to another page (which is
>> not a
>> J2EE Application)
> 
> I'm not sure I'm clear on what you want to accomplish. If you want to 
> post a form to a page at a different URL outside your application, just 
> use that URL as the form's action. Your Struts application needn't be 
> involved at all.
> 
> If the intention is to submit a form and have it processed by *both* 
> your Struts app *and* an external resource, things are a little 
> trickier. In that case, your Struts action would have to construct a new 
> HTTP POST request using the request parameters it received from the 
> browser. Your action would then handle sending the request to the remote 
> resource (and streaming the response back to the browser if required), 
> acting as a kind of pseudo-proxy.
> 
> Perhaps you could explain what your overall objective is; perhaps this 
> isn't the right approach to take to the problem.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S1--Best-practice-to-transfer-control-to-next-page-%28out-of-JVM%29--tp14280321p15021713.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S1] Best practice to transfer control to next page (out of JVM)?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Tue, January 22, 2008 10:56 am, enthucoder wrote:
>
> Can  you give some pointers on how do i contruct a HTTP POST Message in my
> Action and redirect the page to remote resource (non J2EE App)..?

You wouldn't, in all probability, want to construct your own HTTP
requests... take a look at HTTP Components (formerly Jakarta Commons
HTTPClient):

http://hc.apache.org/httpclient-3.x/

It should provide everything you need without you having to mess with all
the gory details.

Frank

-- 
Frank W. Zammetti
Author of "Practical DWR 2 Projects"
 (2008, Apress, ISBN 1-59059-941-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
and "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

>
> Laurie Harper wrote:
>>
>> enthucoder wrote:
>>> Hi,
>>>
>>> Please bear with me, incase this turns out to be a dumb question.
>>>
>>> I want to transfer control to a non JSP page after I hit submit. Apart
>>> from
>>> this I am also sending some data as a HTTPS POST. In case of using
>>> response.sendRedirect(), it doesn't take care of the POST data.
>>>
>>> So, can anybody help me with what's the best practice in sending POST
>>> request from a Struts based J2EE application to another page (which is
>>> not a
>>> J2EE Application)
>>
>> I'm not sure I'm clear on what you want to accomplish. If you want to
>> post a form to a page at a different URL outside your application, just
>> use that URL as the form's action. Your Struts application needn't be
>> involved at all.
>>
>> If the intention is to submit a form and have it processed by *both*
>> your Struts app *and* an external resource, things are a little
>> trickier. In that case, your Struts action would have to construct a new
>> HTTP POST request using the request parameters it received from the
>> browser. Your action would then handle sending the request to the remote
>> resource (and streaming the response back to the browser if required),
>> acting as a kind of pseudo-proxy.
>>
>> Perhaps you could explain what your overall objective is; perhaps this
>> isn't the right approach to take to the problem.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/-S1--Best-practice-to-transfer-control-to-next-page-%28out-of-JVM%29--tp14280321p15021713.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



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