<%@page contentType="text/html;charset=GB2312" %>
<html><body>
<form action="savemessage.jsp" method=post name=form>
<br><br>
<br>姓名<INPUT type="text" name="b"><br>
<br>身高<INPUT type="text" name="a"><br>
<br>年龄<INPUT type="text" name="c"><br>
<br><input type="submit"value="提交内容"name="submit">
</form>
<form action="showmessage.jsp" method=post name=form>
<input type="submit"value="查看内容"name="submit1">
</form>
</body></html>
savemassage.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import ="java.io.*" %>
<HTML><BODY bgcolor=cyan><FONT size=2>
<%
String s= request.getParameter("b");
String s1= request.getParameter("a");
String s2= request.getParameter("c");
File dir=new File("D:/","Students");
dir.mkdir();
File f=new File(dir,"hello.txt");
try{
FileOutputStream outfile=new FileOutputStream(f);
BufferedOutputStream bufferout=new BufferedOutputStream(outfile);
String ss="<table border=2><tr><th>姓名<th>身高<th>年龄</tr>"+"<td>"+s+"</td>"+"<td>"+s1+"</td>"+"<td>"+s2;
byte c[]=ss.getBytes();
bufferout.write(c);
bufferout.flush();
bufferout.close();
outfile.close();
out.print("保存成功!");
}
catch(IOException e){}
%>
</FONT></BODY></HTML>
showmessage.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import ="java.io.*" %>
<HTML><BODY bgcolor=cyan><FONT size=2>
<%
File f= new File("D:/Students/hello.txt");
StringBuffer s=new StringBuffer();
try{
FileReader outfile=new FileReader(f);
BufferedReader bufferin=new BufferedReader(outfile);
String temp;
while((temp=bufferin.readLine())!=null)
s.append(temp);
bufferin.close();
outfile.close();
out.print(s);
}
catch(IOException e){}
%>
</FONT></BODY></HTML>