【JSP开源代码栏目提醒】:网学会员鉴于大家对JSP开源代码十分关注,论文会员在此为大家搜集整理了“update.jsp”一文,供大家参考学习
<%@ page import="java.io.*" contentType="text/html;charset=gb2312" %>
<%
request.setCharacterEncoding("gb2312");
if(request.getParameter("love")!=null)
{
String t=request.getParameter("love");
String f=application.getRealPath("file.txt");
PrintWriter p=new PrintWriter(new FileWriter(f));
p.print(t);
p.close();
out.print("<h2>文本内容已经更新!</h2>");
}
%>
<form action =update.jsp method=post>
更新文本文件内容<br>
<textarea rows=2 cols=30 name='love'></textarea>
<input type=submit value="更新文本文件内容">
</form>
<hr>
<%
out.print("<h4>现在的文本内容:</h4>");
String f=application.getRealPath("file.txt");
BufferedReader br=new BufferedReader(new FileReader(f));
String s=br.readLine();
while(s!=null)
{
out.print(s);
s=br.readLine();
}
%>
上一篇:
update-stu2.jsp
下一篇:
爱情只不过就是,爱与不爱