【JSP开源代码栏目提醒】:本文主要为网学会员提供ex9_14.jsp,希望对需要ex9_14.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_14.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();
}
DataOutputStream dataout=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
dataout.writeUTF(content);
dataout.close();
}
%>
</body>
</html>
上一篇:
ex9_13.jsp
下一篇:
经济可持续发展论文:将可持续发展内生化的新经济发展方式