1

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?

daxim
  • 39,270
  • 4
  • 65
  • 132
Rudiger
  • 6,749
  • 13
  • 51
  • 102
  • Removed the Perl and CGI tags because this question is basically about how to make a HTTP request from Java/JSP, the other technologies don't enter into it. – daxim Feb 23 '11 at 07:39

2 Answers2

2

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:

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.

Community
  • 1
  • 1
FilipK
  • 626
  • 1
  • 4
  • 13
1

Use JSTL <c:import>. If not done yet or your server doesn't support it, first install JSTL. Then do:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...
<c:import url="http://example.com/cgi-bin/perl.pl" />

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555