2014-11-03 63 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); 
    }