如何将我的java servlet的结果包含在php文件中?

Let's say I have two websites. A Java web app running at www.server100.com, and a PHP web app running at www.server200.com.

Let's say I have a servlet http://www.server100.com/webapp1/getImageServlet that returns the following HTML content, where the filename in the html (ABC123.jpg) is a different filename for every hour of the day:

<div id="dynamicImage">
  <img src="http://www.server100.com/ABC123.jpg">
</div>

Now, let's say I have a PHP file here: http://www.server200.com/test1.php. How do I include the HTML that results from the servlet in my PHP file?

I'm thinking I want to do something like ...

<?php
  Print "<html><body>";
  Print "Hi!  Let's see this hour's image!";
  include "http://www.server100.com/webapp1/getImageServlet";
  Print "</body></html>";
?>

Any ideas are greatly appreciated! And would it simplify things if the Java app and the PHP app were running on the same server? Thanks!

I think I have figured it out ...

Print file_get_contents("http://www.server100.com/webapp1/getImageServlet");

... seems to do what I need.

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title</title>
    </head>
    <body>
    <?php 

    //your PHP goes here
        file_get_contents("http://www.server100.com/webapp1/getImageServlet");
    ?>    
    </body>
</html>

save this as whatever.php


if your servlet outputs HTML just do this

<?php

$handle = fopen("http://www.server100.com/webapp1/getImageServlet", "r"); 

$contents = '';

while (!feof($handle)) {

 $contents .= fread($handle, 8192);

}

fclose($handle);

echo $contents; //printing it all out

?>

also echoing file_get_contents() should work just fine