tags:

views:

53

answers:

4

Hello,

I have 1 php page that is doing some manipulation and store data in 2 variable, now I want to pass this data to another page and that page is in jsp. I dont want to click anywhere, mean my php will call automatically to jsp page in last.

Please tell me how can i do this.

Thanks, Manoj Singhal

A: 

You can use CURL to fetch data from the JSP page and then show it to your PHP client. In this scenario, your client (browser) will connect to your JSP application server internally and you can pass data through a URL. After that, you use your JSP output as PHP output.

Pablo Santa Cruz
Hello, I want to send my data from PHP to JSP.
Manoj Singhal
Hello. Try using CURL as I suggested. Otherwise ITroubs' answer is a pretty good alternative also.
Pablo Santa Cruz
read this for passing post data via curl: http://stackoverflow.com/questions/28395/passing-post-values-with-curl
ITroubs
+2  A: 

eitehr store the data in a file or a database and do a header('Location: thejsp.jsp'); die();

and then let the jsp retreive the data from that file or database.

You also could do some curl requests passing the data via get or post

ITroubs
+3  A: 

Try this

<?php
  $var1 = 'some_value';
  $var2 = 'some_other_value';
  header('Location: jsppage.jsp?var1='.$var1.'&var2='.$var2);
  exit;
?>

You values will be available in jsp script trough request.getParameter("var1") and request.getParameter("var2") (might be wrong, have very little knowledge on jsp).

egis
+1  A: 

Assuming that you want to reuse the same request parameters on the JSP:

If it's a GET request, do:

header('HTTP/1.1 302 Moved Temporarily');
header('Location: http://example.com/page.jsp?' . $_SERVER['QUERY_STRING']);
exit();

If it's a POST request, do:

header('HTTP/1.1 307 Temporary Redirect');
header('Location: http://example.com/page.jsp');
exit();

(with a 307 the client will reapply the POST request including parameters on the target page)

BalusC