doucan1996 2013-09-20 00:51
浏览 26
已采纳

如何将我的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!

  • 写回答

2条回答 默认 最新

  • douqianzha6213 2013-09-20 01:02
    关注

    I think I have figured it out ...

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

    ... seems to do what I need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据