【JSP开源代码栏目提醒】:网学会员,鉴于大家对JSP开源代码十分关注,论文会员在此为大家搜集整理了“ex9_08.jsp”一文,供大家参考学习!
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!--基于字符流的文件写入-->
<%@ page import="java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>JSP通用范例大全</title>
</head>
<body>
<center><font size=5>文件的写入</font></center>
<br><hr><br>
<form name="chat" method="post" action="ex9_08.jsp">
写入文件的内容<input type="text" name="content" value="">
<input type="submit" name="Submit" value="提交">
</form>
<br>
<%
request.setCharacterEncoding("GB2312");
String content=request.getParameter("content");
if(content!=null){
File file=new File(request.getRealPath("/")+"chat.txt");
if(!file.exists()){
file.createNewFile();
}
FileWriter fw=new FileWriter(file,true);
fw.write(content);
fw.close();
}
%>
</body>
</html>
上一篇:
ex9_07.jsp
下一篇:
2019年湖南省成人高考成绩查询入口已开通参考资料