I have given a my code, when i try to execute it the contents of a file log1.txt is not displayed on
jsp page. I find no errors . please let me know the where the problem is :
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%!
String fileOutput;
%>
<%@ page
import="java.lang.*"
import="java.util.Scanner"
import="java.io.FileReader"
import="java.net.*"
%>
<%!
class DisplayLog {
void display(){
try {
String fileName;
String s2="c:/example/log1.txt";
StringBuffer buffer = new StringBuffer();
Scanner scan = new Scanner(new FileReader(s2));
String readdata="";
while ((readdata=scan.nextLine())!=null){
buffer.append(readdata).append('\n');
}
fileOutput = buffer.toString();
}catch(Exception e)
{
}
}
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="blue">
<tr>
<CENTER> <img src="images/logo.jpg" width="50" height="60" alt="logo"/><h1>Project</h1> </CENTER>
</tr>
<center><h2>Debug Mode</h2></center>
<HR WIDTH="100%" SIZE="3" NOSHADE>
<FORM METHOD=post ACTION="/cgi-bin/example.cgi">
<!-- <textarea name="txtAreaLog" cols="30" rows="20" readonly="readonly" title="log area"> </textarea> -->
<textarea rows="20" cols="62" readonly =" readonly" WRAP="off"><%= (fileOutput != null) ? fileOutput : "" %></textarea>
</FORM>
<FORM METHOD=post ACTION="/cgi-bin/example.cgi">
Enter file name:<BR>
<INPUT type="text" size="10" maxlength="30">
<INPUT type="Submit" VALUE="Submit">
</FORM>
<div align="right">[ <A href="logout.jsp" style=""><font style="font-family:verdana; font-size:70%;" color="blue"><b>L</b>ogout</font></A> ]</div>
</body>
</html>