You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pat <cp...@yahoo.com> on 2007/04/17 03:26:01 UTC

newbie alert: forward to a php script

Hello
Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.

Re: newbie alert: forward to a php script

Posted by Laurie Harper <la...@holoweb.net>.
I'm not really clear on what you're trying to achieve, but it sounds 
like you just need to read the HTTP response from the request you make 
through HttpClient. Since you're making that request from your action 
and, therefore, will have the response available there too, you don't 
need to 'direct it to an action'; you're already in an action.

If you're still having trouble, try describing the overall problem 
you're trying to solve.

L.

Chris Pat wrote:
> Hi Laurie
> Thank you for continuing to help my naivete.  I saw two problems: one I didnt know how to format and send a forward out of the struts framework, two the response will only come back on the port and without any context so I cant direct it to an Action(possibly even the same as the pre-processing) to receive and post-process the response.  Am I able to do any of these natively within Struts?  I have the first part working with HttpClient, but working out the second half of the php script getting the response and sending it to my Action.  Again thank you.
> 
> Laurie Harper <la...@holoweb.net> wrote: I'm still not clear why you need the PHP script at all; why not call out 
> to the remote server directly from your Java webapp? That would seem to 
> be a simpler route.
> 
> However, if you really do need the PHP script in there something like 
> HttpClient, as suggested by another poster, would probably be the 
> easiest way to build and submit the HTTP request.
> 
> L.
> 
> Chris Pat wrote:
>> Hi Laurie
>> Thanks.  All I need is to send a HTTP Post request to  the php script with the parameters that the Action received, but having done some processing in the Action.  At this point I dont care if the client sees the results of the php output.  I dont see how to generate something like a RequestDisptacher from within an Action even if I just send the client to a success page at the end.
>>
>> My design problem is that I am trying to talk to a cc processor using struts code.  Right now the only way I can send the post to the cc processor and receive the response on the same port is with a php script.  So I thought of splitting it up and using curl to send to the cc processor after processing it in an Action, receiving it in the php scrip and forwarding it to another Action for post processing.  I have to get around the fact that the cc processor will only send back a response on the same port that the port as the request, obviously without a nicely formatted context/servlet syntax.  I believe this will work, if I can only get a post sent to the php script which will be a url outside of the Struts framework.  I am sure this massively violative MVC and probably not scalable, but I just have to get it done.  Thanks for even the slightest insight, even if saying it is utterly st
>  up
>>  id, grin.
>>
>> Laurie Harper  wrote: Chris Pat wrote:
>>> Hello
>>> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.
>> Post to? Sure, you can create an HTTP POST request to any URL. But I 
>> suspect that's not quite what you mean. If you mean /forward/ to, as in 
>> dispatch to, a PHP script, it's not so straight forward.
>>
>> I seem to recall seeing mention on this list in the past of some sort of 
>> Java-PHP bridge, which may be what you're looking for. Search the 
>> archives (or Google) for 'Java PHP bridge' and see if that turns 
>> anything useful up. Alternatively, re-post with clarification of exactly 
>> what you want to achieve; maybe someone will be able to give a more 
>> specific solution.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 


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


Re: newbie alert: forward to a php script

Posted by Chris Pat <cp...@yahoo.com>.
Hi Laurie
Thank you for continuing to help my naivete.  I saw two problems: one I didnt know how to format and send a forward out of the struts framework, two the response will only come back on the port and without any context so I cant direct it to an Action(possibly even the same as the pre-processing) to receive and post-process the response.  Am I able to do any of these natively within Struts?  I have the first part working with HttpClient, but working out the second half of the php script getting the response and sending it to my Action.  Again thank you.

Laurie Harper <la...@holoweb.net> wrote: I'm still not clear why you need the PHP script at all; why not call out 
to the remote server directly from your Java webapp? That would seem to 
be a simpler route.

However, if you really do need the PHP script in there something like 
HttpClient, as suggested by another poster, would probably be the 
easiest way to build and submit the HTTP request.

L.

Chris Pat wrote:
> Hi Laurie
> Thanks.  All I need is to send a HTTP Post request to  the php script with the parameters that the Action received, but having done some processing in the Action.  At this point I dont care if the client sees the results of the php output.  I dont see how to generate something like a RequestDisptacher from within an Action even if I just send the client to a success page at the end.
> 
> My design problem is that I am trying to talk to a cc processor using struts code.  Right now the only way I can send the post to the cc processor and receive the response on the same port is with a php script.  So I thought of splitting it up and using curl to send to the cc processor after processing it in an Action, receiving it in the php scrip and forwarding it to another Action for post processing.  I have to get around the fact that the cc processor will only send back a response on the same port that the port as the request, obviously without a nicely formatted context/servlet syntax.  I believe this will work, if I can only get a post sent to the php script which will be a url outside of the Struts framework.  I am sure this massively violative MVC and probably not scalable, but I just have to get it done.  Thanks for even the slightest insight, even if saying it is utterly stup
>  id, grin.
> 
> Laurie Harper  wrote: Chris Pat wrote:
>> Hello
>> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.
> 
> Post to? Sure, you can create an HTTP POST request to any URL. But I 
> suspect that's not quite what you mean. If you mean /forward/ to, as in 
> dispatch to, a PHP script, it's not so straight forward.
> 
> I seem to recall seeing mention on this list in the past of some sort of 
> Java-PHP bridge, which may be what you're looking for. Search the 
> archives (or Google) for 'Java PHP bridge' and see if that turns 
> anything useful up. Alternatively, re-post with clarification of exactly 
> what you want to achieve; maybe someone will be able to give a more 
> specific solution.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> 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



Re: newbie alert: forward to a php script

Posted by Laurie Harper <la...@holoweb.net>.
I'm still not clear why you need the PHP script at all; why not call out 
to the remote server directly from your Java webapp? That would seem to 
be a simpler route.

However, if you really do need the PHP script in there something like 
HttpClient, as suggested by another poster, would probably be the 
easiest way to build and submit the HTTP request.

L.

Chris Pat wrote:
> Hi Laurie
> Thanks.  All I need is to send a HTTP Post request to  the php script with the parameters that the Action received, but having done some processing in the Action.  At this point I dont care if the client sees the results of the php output.  I dont see how to generate something like a RequestDisptacher from within an Action even if I just send the client to a success page at the end.
> 
> My design problem is that I am trying to talk to a cc processor using struts code.  Right now the only way I can send the post to the cc processor and receive the response on the same port is with a php script.  So I thought of splitting it up and using curl to send to the cc processor after processing it in an Action, receiving it in the php scrip and forwarding it to another Action for post processing.  I have to get around the fact that the cc processor will only send back a response on the same port that the port as the request, obviously without a nicely formatted context/servlet syntax.  I believe this will work, if I can only get a post sent to the php script which will be a url outside of the Struts framework.  I am sure this massively violative MVC and probably not scalable, but I just have to get it done.  Thanks for even the slightest insight, even if saying it is utterly stup
>  id, grin.
> 
> Laurie Harper <la...@holoweb.net> wrote: Chris Pat wrote:
>> Hello
>> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.
> 
> Post to? Sure, you can create an HTTP POST request to any URL. But I 
> suspect that's not quite what you mean. If you mean /forward/ to, as in 
> dispatch to, a PHP script, it's not so straight forward.
> 
> I seem to recall seeing mention on this list in the past of some sort of 
> Java-PHP bridge, which may be what you're looking for. Search the 
> archives (or Google) for 'Java PHP bridge' and see if that turns 
> anything useful up. Alternatively, re-post with clarification of exactly 
> what you want to achieve; maybe someone will be able to give a more 
> specific solution.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> 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


Re: newbie alert: forward to a php script

Posted by Chris Pat <cp...@yahoo.com>.
Hi IG
That looks like the object.  Thanks.

Information Guzzler <in...@gmail.com> wrote: Hi Chris,

HttpClient would be an alternative to generate HTTP POST request. For info.
refer

http://jakarta.apache.org/commons/httpclient/

/I

On 4/17/07, Chris Pat  wrote:
>
> Hello
> Sorry for the persistence/naivete of this, however can someone tell me if
> this is possible and how?  It will be a learning experience for me and I
> appreciate any insight.
>
> Chris Pat  wrote: Hi Laurie
> Thanks.  All I need is to send a HTTP Post request to  the php script with
> the parameters that the Action received, but having done some processing in
> the Action.  At this point I dont care if the client sees the results of the
> php output.  I dont see how to generate something like a RequestDisptacher
> from within an Action even if I just send the client to a success page at
> the end.
>
> My design problem is that I am trying to talk to a cc processor using
> struts code.  Right now the only way I can send the post to the cc processor
> and receive the response on the same port is with a php script.  So I
> thought of splitting it up and using curl to send to the cc processor after
> processing it in an Action, receiving it in the php scrip and forwarding it
> to another Action for post processing.  I have to get around the fact that
> the cc processor will only send back a response on the same port that the
> port as the request, obviously without a nicely formatted context/servlet
> syntax.  I believe this will work, if I can only get a post sent to the php
> script which will be a url outside of the Struts framework.  I am sure this
> massively violative MVC and probably not scalable, but I just have to get it
> done.  Thanks for even the slightest insight, even if saying it is utterly
> stupid, grin.
>
> Laurie Harper  wrote: Chris Pat wrote:
> > Hello
> > Is it possible to have an Action that processes some data and then posts
> to a url completely out of control of the framework?  I want to process and
> write to a db first and then using the same parameters and any added session
> variables post to a php script, initially running on localhost but
> eventually on a completely different url.  Can someone help me understand
> how or why not.  I really need to do it even if it is not to the
> spec.  Thank you.
>
> Post to? Sure, you can create an HTTP POST request to any URL. But I
> suspect that's not quite what you mean. If you mean /forward/ to, as in
> dispatch to, a PHP script, it's not so straight forward.
>
> I seem to recall seeing mention on this list in the past of some sort of
> Java-PHP bridge, which may be what you're looking for. Search the
> archives (or Google) for 'Java PHP bridge' and see if that turns
> anything useful up. Alternatively, re-post with clarification of exactly
> what you want to achieve; maybe someone will be able to give a more
> specific solution.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>


Re: newbie alert: forward to a php script

Posted by Information Guzzler <in...@gmail.com>.
Hi Chris,

HttpClient would be an alternative to generate HTTP POST request. For info.
refer

http://jakarta.apache.org/commons/httpclient/

/I

On 4/17/07, Chris Pat <cp...@yahoo.com> wrote:
>
> Hello
> Sorry for the persistence/naivete of this, however can someone tell me if
> this is possible and how?  It will be a learning experience for me and I
> appreciate any insight.
>
> Chris Pat <cp...@yahoo.com> wrote: Hi Laurie
> Thanks.  All I need is to send a HTTP Post request to  the php script with
> the parameters that the Action received, but having done some processing in
> the Action.  At this point I dont care if the client sees the results of the
> php output.  I dont see how to generate something like a RequestDisptacher
> from within an Action even if I just send the client to a success page at
> the end.
>
> My design problem is that I am trying to talk to a cc processor using
> struts code.  Right now the only way I can send the post to the cc processor
> and receive the response on the same port is with a php script.  So I
> thought of splitting it up and using curl to send to the cc processor after
> processing it in an Action, receiving it in the php scrip and forwarding it
> to another Action for post processing.  I have to get around the fact that
> the cc processor will only send back a response on the same port that the
> port as the request, obviously without a nicely formatted context/servlet
> syntax.  I believe this will work, if I can only get a post sent to the php
> script which will be a url outside of the Struts framework.  I am sure this
> massively violative MVC and probably not scalable, but I just have to get it
> done.  Thanks for even the slightest insight, even if saying it is utterly
> stupid, grin.
>
> Laurie Harper  wrote: Chris Pat wrote:
> > Hello
> > Is it possible to have an Action that processes some data and then posts
> to a url completely out of control of the framework?  I want to process and
> write to a db first and then using the same parameters and any added session
> variables post to a php script, initially running on localhost but
> eventually on a completely different url.  Can someone help me understand
> how or why not.  I really need to do it even if it is not to the
> spec.  Thank you.
>
> Post to? Sure, you can create an HTTP POST request to any URL. But I
> suspect that's not quite what you mean. If you mean /forward/ to, as in
> dispatch to, a PHP script, it's not so straight forward.
>
> I seem to recall seeing mention on this list in the past of some sort of
> Java-PHP bridge, which may be what you're looking for. Search the
> archives (or Google) for 'Java PHP bridge' and see if that turns
> anything useful up. Alternatively, re-post with clarification of exactly
> what you want to achieve; maybe someone will be able to give a more
> specific solution.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>

Re: newbie alert: forward to a php script

Posted by Chris Pat <cp...@yahoo.com>.
Hello
Sorry for the persistence/naivete of this, however can someone tell me if this is possible and how?  It will be a learning experience for me and I appreciate any insight.  

Chris Pat <cp...@yahoo.com> wrote: Hi Laurie
Thanks.  All I need is to send a HTTP Post request to  the php script with the parameters that the Action received, but having done some processing in the Action.  At this point I dont care if the client sees the results of the php output.  I dont see how to generate something like a RequestDisptacher from within an Action even if I just send the client to a success page at the end.

My design problem is that I am trying to talk to a cc processor using struts code.  Right now the only way I can send the post to the cc processor and receive the response on the same port is with a php script.  So I thought of splitting it up and using curl to send to the cc processor after processing it in an Action, receiving it in the php scrip and forwarding it to another Action for post processing.  I have to get around the fact that the cc processor will only send back a response on the same port that the port as the request, obviously without a nicely formatted context/servlet syntax.  I believe this will work, if I can only get a post sent to the php script which will be a url outside of the Struts framework.  I am sure this massively violative MVC and probably not scalable, but I just have to get it done.  Thanks for even the slightest insight, even if saying it is utterly stupid, grin.

Laurie Harper  wrote: Chris Pat wrote:
> Hello
> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.

Post to? Sure, you can create an HTTP POST request to any URL. But I 
suspect that's not quite what you mean. If you mean /forward/ to, as in 
dispatch to, a PHP script, it's not so straight forward.

I seem to recall seeing mention on this list in the past of some sort of 
Java-PHP bridge, which may be what you're looking for. Search the 
archives (or Google) for 'Java PHP bridge' and see if that turns 
anything useful up. Alternatively, re-post with clarification of exactly 
what you want to achieve; maybe someone will be able to give a more 
specific solution.

L.


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




Re: newbie alert: forward to a php script

Posted by Chris Pat <cp...@yahoo.com>.
Hi Laurie
Thanks.  All I need is to send a HTTP Post request to  the php script with the parameters that the Action received, but having done some processing in the Action.  At this point I dont care if the client sees the results of the php output.  I dont see how to generate something like a RequestDisptacher from within an Action even if I just send the client to a success page at the end.

My design problem is that I am trying to talk to a cc processor using struts code.  Right now the only way I can send the post to the cc processor and receive the response on the same port is with a php script.  So I thought of splitting it up and using curl to send to the cc processor after processing it in an Action, receiving it in the php scrip and forwarding it to another Action for post processing.  I have to get around the fact that the cc processor will only send back a response on the same port that the port as the request, obviously without a nicely formatted context/servlet syntax.  I believe this will work, if I can only get a post sent to the php script which will be a url outside of the Struts framework.  I am sure this massively violative MVC and probably not scalable, but I just have to get it done.  Thanks for even the slightest insight, even if saying it is utterly stupid, grin.

Laurie Harper <la...@holoweb.net> wrote: Chris Pat wrote:
> Hello
> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.

Post to? Sure, you can create an HTTP POST request to any URL. But I 
suspect that's not quite what you mean. If you mean /forward/ to, as in 
dispatch to, a PHP script, it's not so straight forward.

I seem to recall seeing mention on this list in the past of some sort of 
Java-PHP bridge, which may be what you're looking for. Search the 
archives (or Google) for 'Java PHP bridge' and see if that turns 
anything useful up. Alternatively, re-post with clarification of exactly 
what you want to achieve; maybe someone will be able to give a more 
specific solution.

L.


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



Re: newbie alert: forward to a php script

Posted by Laurie Harper <la...@holoweb.net>.
Chris Pat wrote:
> Hello
> Is it possible to have an Action that processes some data and then posts to a url completely out of control of the framework?  I want to process and write to a db first and then using the same parameters and any added session variables post to a php script, initially running on localhost but eventually on a completely different url.  Can someone help me understand how or why not.  I really need to do it even if it is not to the spec.  Thank you.

Post to? Sure, you can create an HTTP POST request to any URL. But I 
suspect that's not quite what you mean. If you mean /forward/ to, as in 
dispatch to, a PHP script, it's not so straight forward.

I seem to recall seeing mention on this list in the past of some sort of 
Java-PHP bridge, which may be what you're looking for. Search the 
archives (or Google) for 'Java PHP bridge' and see if that turns 
anything useful up. Alternatively, re-post with clarification of exactly 
what you want to achieve; maybe someone will be able to give a more 
specific solution.

L.


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