jsp中的TXT文件未显示

时间:2012-08-15 20:15:33

标签: java jsp

嘿,我编写了一个JSP,它从文件系统中获取.txt文件并需要逐行显示。但由于某种原因它没有显示。提前谢谢

<html>
<head>
<title>DrAssist Reporting Tool</title>
</head>
<body>
    <p>Welcome to the DrAssist Reporting Tool</p>
    <p>Suite Report Information</p>
    <h1>Suite : ${suite}</h1>
    <h1>NoOfTests:${noOfTests}</h1> 
    <h1>Test Name:${TestName}</h1>  
    <h1>FitnesseRestURL:${FitnesseRestURL}</h1> 
    <h1>Rights:${rights}</h1>   
    <h1>Wrongs:${wrongs}</h1>   
    <h1>Ignores:${ignores}</h1> 
    <h1>Exceptions:${exceptions}</h1>   
    <h1>TimeinMilliseconds:${timeOfExecution}</h1>  
    <%@ include file="Test1.html" %>
    <%@ page language="java" import="java.net.Authenticator,java.net.PasswordAuthentication,java.io.BufferedReader,java.net.*,java.io.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
     <%
     BufferedReader input = new BufferedReader(new FileReader("C:\\DrAssistQA\\reports\\120703-100125\\log-120703-100125.txt"));
     String line = "";
     while ((line = input.readLine()) != null) {
     System.out.println(line);
}
  out.flush();
  input.close();
%>


<%=line%>



</body>
</html>

2 个答案:

答案 0 :(得分:0)

它不是浏览器窗口而是你的系统。请改为response.write()

答案 1 :(得分:0)

使用out.println代替System.out.printlnout是在JSP中自动创建的用于浏览器输出流操作的变量。另外不要忘记HTML换行符。

while ((line = input.readLine()) != null) {
     out.println(line + "<BR>");
}