how to display the contents of textfile in textarea at runtime using JSP
plaese help me out!!!!!!:confused:
Hi, my code is reading only the last line from the textfile and displaying in the textraea. i want that it should display whole textfile in the textarea on buton click event.i'm attaching the code:
<%@ page import= "java.lang.*, java.io.*, java.util.*" %>
<%
File file = new File("E:/MISReport/public_html/test.txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
String s1=null;
%>
<HTML>
<HEAD><TITLE>Select Report Group</TITLE>
<script language="javascript">
function goBack()
{
document.selectreportgroup.action="log.jsp";
document.selectreportgroup.submit();
}
</script>
<script language="javascript">
function dosubmit()
{
<%
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
for(int i=0;i<dis.available();i++){
%>document.getElementById("txtAreaLog").value="<%= dis.readLine()%>";
<%}%>
}
</script>
</HEAD>
<BODY bgColor=white leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="dosubmit()">
<%
String username = (String)session.getAttribute("passuname");
String password = (String)session.getAttribute("passpass");
if(username==""||password=="")
{%>
<jsp:forward page="index.jsp"></jsp:forward>
<%}
%>
<FORM name="selectreportgroup" method="post" >
<div align="center">
<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>
<IMG src="images/lds.gif" alt="">
<TABLE width="100%" align="center" bgColor="white" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td nowrap='nowrap' height="10" align="center" colspan="7" style="font-family:verdana; font-size:70%; background-color: #EA0000; color: white;" ><b>LOG GROUP</b></td>
</tr>
</TABLE>
<BR>
<table width="60%" border="0.0" style="font-family:Verdana, Arial, Helvetica, sans-serif">
<TR>
<td>
<textarea name="txtAreaLog" cols="120" rows="20" readonly="readonly" title="log area"> </textarea>
</td>
<TR>
<TR>
<TD align="center">
<input style="font-family:verdana; font-size:100%;" type="button" value="Go Back" onclick="javaScript:goBack();">
<INPUT style="font-family:verdana; font-size:100%;" type="reset" value=" Clear ">
<input style="font-family:verdana; font-size:100%;" type="button" value="First" onclick="dosubmit(report_type.value);"/>
<input style="font-family:verdana; font-size:100%;" type="button" value="Previous" onclick="dosubmit(report_type.value);"/>
<INPUT style="font-family:verdana; font-size:100%;" type="button" value="Next" onclick="dosubmit(report_type.value);">
<input style="font-family:verdana; font-size:100%;" type="button" value="Last" onclick="dosubmit(report_type.value);"/>
</TD>
</TR>
</table>
</div>
</FORM>
</BODY>
</HTML>