I am writting some sort of a proxy & uses HttpClient to execute the request.
The HttpClient does the request (POST) as expected & I can see that the answer is coming.
I just need to copy the HttpResponse received as the Struts "full" response.

This prooved to be more challenging than expected as the simple copy of the whole reponse is currently NOT OK.

I stored the whole HTML-response in the variable content :
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:property value="content" />
does not fill the page with the HTML-content retrieve from the other request


and writing directly on the Struts response :
response.getWriter().write(content);

Any idea would be appreciated ... as it is basically copying an HTML content from one to the other !!!

\T,











--

Subject: Re: [S1] Best practice to transfer control to next page (out of JVM)?
From: Frank W. Zammetti
Date: Jan 22, 2008 8:10:54 am
List: org.apache.struts.user

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

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.




--
Thomas Lionel SMETS, CISSP (385434)
m : +32 497 44 68 12
ph : +32 2 852 3341
skype : thomas.lionel.smets

PGP = FDF0 8FB8 4F37 3F79 1011 05AB 0DCE 9BAB 5DD0 0E10

<<attachment: tsmets.vcf>>

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to