2014-11-03 67 views
1

我想直接在jsp页面上输出perl脚本的输出。 我一直在我的JSP页面上尝试不同的版本,此行:在jsp页面上输出perl脚本

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<c:import url="script.pl" /> 

我把一个脚本在一个项目目录 但不断收到此错误: Servlet.service()的servlet和jsp扔异常 java.io.FileNotFoundException:directories.pl(没有这样的文件或目录)

因此,我应该把我的脚本,我如何打印它的输出到jsp页面? 谢谢

回答

0

我最终设法以不同的方式做到这一点。这对我来说比较好,因为我希望操纵我收到的数据,并将它放在页面上的表格中

try { 
     Runtime r = Runtime.getRuntime();      
     Process p = r.exec("/actualdirforscript/scripts/ls.pl"); 
     BufferedReader in = 
      new BufferedReader(new InputStreamReader(p.getInputStream())); 
     String inputLine; 
     while ((inputLine = in.readLine()) != null) { 
       out.print(inputLine); 
     } 
     in.close(); 
    } catch (IOException e) { 
     System.out.println(e); 
    }