如何将动态 Web 内容提取到 JSP 页面中?
我确信这确实很简单,但我很难从大量其他文档中找到文档,而且我与 Perl 关系不大。
我在 http://example.com/cgi-bin/perl.pl
上有一个脚本。它输出一些文本。我希望能够将此输出拉入 JSP 页面。
您知道解释如何执行此操作的任何示例或网站吗?
I'm sure this is really simple, but I have trouble finding documentation from an avalanche of other docs and I've had very little to do with Perl.
I have a script at http://example.com/cgi-bin/perl.pl
. It outputs some text. I want to be able to pull this output into a JSP page.
Do you know any examples of or websites that explain how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题似乎是关于 JSP 而不是 Perl。从任何动态脚本(如 Perl 中的脚本)提取输出意味着您需要在 JSP 页面中包含该脚本生成的输出。您没有提到脚本是否输出 HTML 或其他格式,但假设它是 HTML,您可以做两件事:
包含
http://example.com/cgi-bin/perl.pl 作为
IFRAME
(a JSP 页面中的标准 HTML 元素无论脚本的输出格式如何,后一种方法都将起作用。不过,我建议不要将 Java 代码直接放入 JSP 中。最好将其放入 JavaBean 帮助器甚至自定义 JSP 标记中。
Your question seems to be about JSP and not Perl. Pulling output from any dynamic script (like the one in Perl) means you need to include generated output from that script in your JSP page. You didn't mention if the script outputs HTML or some other format, but assuming it's HTML, you can do two things:
Include
http://example.com/cgi-bin/perl.pl
as anIFRAME
(a standard HTML element) in the JSP pagePull the content using Java code, preferably using a dedicated library (see Pulling HTML from a Webpage in Java)
The latter method will work regardless of the output format of the script. I'd recommend however against putting the Java code directly inside JSP. It's better to put it in a JavaBean helper or even a custom JSP tag.
使用 JSTL
;
。如果尚未完成或您的服务器不支持它,请首先安装 JSTL。然后做:就是这样。它将内联到所有其他 HTML 中的确切位置。但如果该输出可以包含客户端控制的数据,请注意 XSS。
Use JSTL
<c:import>
. If not done yet or your server doesn't support it, first install JSTL. Then do:That's it. It will be inlined on exactly that place among all other HTML. Be aware of XSS though if that output can contain client-controlled data.