如何在PHP页面中包含JSP [英] How to Include a JSP in a PHP page

查看:178
本文介绍了如何在PHP页面中包含JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望包括JSP在内的PHP模板中包含Java代码的文件.有问题的两个包括头文件和页脚文件.任何人有这样做的经验吗?我们正在考虑仅执行HTTP请求以独立地从JSP文件中获取结果HTML,但是不确定这样做是否会产生轻微的性能问题.

I wish to include JSPs include files which contain java code in a PHP template. The two includes in question are a header file, and a footer file. Anyone any experience of doing this? We are considering just doing a HTTP request to grab the resulting HTML from the JSP files independantly, but aren't sure if there will be slight performance issues with doing so.

使用Apache中的某些工具执行此操作是否有更好的解决方案?

Is there any better solution using some of the tools within Apache to perform this?

推荐答案

echo file_get_contents('http://full/link/to/jsp/page');

如果您的JSP页面回显了标题,正文结构,则需要将其剥离.您可以从JSP端或PHP做到这一点.

If you JSP page echos a header, body structure, you'll need to strip it out. You can do that from the JSP side or PHP.

在某些系统上该功能已禁用,因此您可能需要使用cURL(它还允许您发回邮件,如果您正在使用表格,则可能需要这样做).

That's disabled on some systems so you might need to use cURL (it also allows you to post back which you might need to do if you're playing with forms).

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL, 'http://full/link/to/jsp/page');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
echo curl_exec($ch);

这篇关于如何在PHP页面中包含JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆