jsp修改example5-6

<%@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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值