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 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)