digbyn Posted May 9, 2013 Share Posted May 9, 2013 Hi All,Hoping you can help, have spent many hours searching around and not finding much. I have a main php program running and I wish to make a call to execute a JSP page, sounds simple enough. I have tried include but did not work, header location but this causes header redirect problems and curl which does not work? Also tried file_get_contents, did not work either? I wish to stay in my main.php program and not get redirected, just make a call and successfully execute the JSP page running on another server? Hope this is clear, any help much appreciated.this works... PHP Code: [select] <?php$homepage = file_get_contents('http://www.example.com/');echo $homepage;?>but this does not work PHP Code: [select] <?php$homepage = file_get_contents('http://hostname:8080/pagename.jsp?param1=value1¶m2=value2/');echo $homepage;?> have also tried CURL, also times out. PHP Code: [select] $URL ='http://hostname:8080/pagename.jsp?param1=value1¶m2=value2'; //Initialize the Curl session$ch = curl_init();//Set curl to return the data instead of printing it to the browser.curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set the URLcurl_setopt($ch, CURLOPT_URL, $URL);//Execute the fetch$data = curl_exec($ch) or die(curl_error($ch));//Close the connectioncurl_close($ch);print $data; Quote Link to comment Share on other sites More sharing options...
requinix Posted May 9, 2013 Share Posted May 9, 2013 Both the file_get_contents() and cURL versions should work. If they're timing out then there's a problem accessing that URL. For example, are you sure you have the right hostname? And that it really is on port 8080? By the way, if you're just outputting it then a header() redirect may be appropriate (I don't know what "header redirect problems" are) or, if it has to be code, readfile. Quote Link to comment Share on other sites More sharing options...
Texan78 Posted May 9, 2013 Share Posted May 9, 2013 Does the Js script contain any styling? Quote Link to comment Share on other sites More sharing options...
digbyn Posted May 9, 2013 Author Share Posted May 9, 2013 Hi Requinix, Thanks for the reply, much appreciated, its been years since I last did this! Yes I thought file_get_contents and cURL would work but no, so I assume there is something else going on and will investigate. Yes I have a java app deployed on 8080.I do have it working with header redirect as follows. ... ... ob_end_clean(); header('Location: http://example.com:8080/page.jsp'); exit(); Problem is, thats where the show stops...on that jsp page, I would like to just 'execute' the jsp page and then return to the master main.php program and keep running not redirect permanently to that jsp page. I have program1.php calls program2.php that executes the header redirect but does not return back to program1.php. Sorry, hope this is making sense? Thanks for the help. Digby. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.