This is the situation:
Im writing this site in PHP, and, because of some circumstances completely out of my control, i need to write a php script that dynamically passes every request parameter it recieves and sends it to some java servlet.
The java site has some 40 different servlets that i need to acces.
So im writing an "ajax_forward.php" script that should receive a $_POST['ajax_servlet'] parameter that indicates which servlet the rest of the parameters should be passed on to.
A possible solution might be to have php pass all parameters over to a curl command, but im just wondering if theres a 100% php solution that i just have not been able to stumble upon.
I've googled like crazy but... i guess i just have not used the right combination of keywords.
any ideas?
forward all request parameters to a java Servlet
Moderator: General Moderators
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: forward all request parameters to a java Servlet
When you say 100% php solution, do you mean you don't want to use any external modules like cURL (as in things you'll possibly need to apt-get)?
The first solution to a problem like this that comes to my mind is using cURL.
-Andy
The first solution to a problem like this that comes to my mind is using cURL.
-Andy
Re: forward all request parameters to a java Servlet
cURL sounds great.
I've done mi research and there's only one problem left. How can i dinamycally read all of the request's parameter names and values?
is there a function that returns an array with all of the parameter names?
so i could wirte something like :
for each paramenterNames as paramenter
$URL=$parameter."=".$_POST[$parameter]."&"
can anyone give me an example?
I've done mi research and there's only one problem left. How can i dinamycally read all of the request's parameter names and values?
is there a function that returns an array with all of the parameter names?
so i could wirte something like :
for each paramenterNames as paramenter
$URL=$parameter."=".$_POST[$parameter]."&"
can anyone give me an example?
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: forward all request parameters to a java Servlet
You could do something like this:eljapi wrote:cURL sounds great.
I've done mi research and there's only one problem left. How can i dinamycally read all of the request's parameter names and values?
is there a function that returns an array with all of the parameter names?
so i could wirte something like :
for each paramenterNames as paramenter
$URL=$parameter."=".$_POST[$parameter]."&"
can anyone give me an example?
Code: Select all
$URL = "";
foreach( $_POST as $key => $value )
{
$URL .= "$key=$value&";
}
$URL = rtrim($URL,"&");Re: forward all request parameters to a java Servlet
Why not just proxy or redirect to the serverlet with apache?