提交表单生成html文件的方法
2012-01-11 15:09
295 查看
1、test.html
Java代码
文本格式复制代码打印?
<html>
<body>
<form name = "form1" method = "post" action = "test.jsp ">
<textarea name= "t1 "> </textarea>
<input type = "submit" name = "Submit" value ="Submit ">
</form>
</body>
</html>
2、test.jsp
Java代码
文本格式复制代码打印?
<%@ page contentType = "text/html; charset=GB2312 " language= "java " %>
<%@ page import= "java.util.*,java.text.* "%>
<%@ page import= "java.io.* "%>
<html>
<head>
<title> Deal it </title>
<meta http-equiv = "Content-Type" content = "text/html;charset=gb2312 ">
</HEAD>
<BODY>
<%
String content=request.getParameter( "t1 ");
if(content==null || content.equals( " "))
return;
SimpleDateFormat sdf=new SimpleDateFormat( "yyyyMMdd ");
java.util.Date rightNow = new java.util.Date();
String tmp=sdf.format(rightNow);
System.out.println(tmp);
String filename=request.getRealPath( "/ ")+tmp+ ".html ";
System.out.println(filename);
try {
File theFile=new File(filename);
if (theFile.exists() == true) {
theFile.delete();
}
theFile.createNewFile();
RandomAccessFile fout = new RandomAccessFile(filename, "rw ");
content= " <html> <body> "+content+ " </body> </html> ";
fout.writeBytes(content);
fout.close();
}catch(Exception e) {
e.printStackTrace();
}
System.out.println( "All is Over ");
%>
</BODY>
</HTML>
本文转载自 http://www.itjianghu.net/120108/40916358935185219.htm
Java代码
文本格式复制代码打印?
<html>
<body>
<form name = "form1" method = "post" action = "test.jsp ">
<textarea name= "t1 "> </textarea>
<input type = "submit" name = "Submit" value ="Submit ">
</form>
</body>
</html>
2、test.jsp
Java代码
文本格式复制代码打印?
<%@ page contentType = "text/html; charset=GB2312 " language= "java " %>
<%@ page import= "java.util.*,java.text.* "%>
<%@ page import= "java.io.* "%>
<html>
<head>
<title> Deal it </title>
<meta http-equiv = "Content-Type" content = "text/html;charset=gb2312 ">
</HEAD>
<BODY>
<%
String content=request.getParameter( "t1 ");
if(content==null || content.equals( " "))
return;
SimpleDateFormat sdf=new SimpleDateFormat( "yyyyMMdd ");
java.util.Date rightNow = new java.util.Date();
String tmp=sdf.format(rightNow);
System.out.println(tmp);
String filename=request.getRealPath( "/ ")+tmp+ ".html ";
System.out.println(filename);
try {
File theFile=new File(filename);
if (theFile.exists() == true) {
theFile.delete();
}
theFile.createNewFile();
RandomAccessFile fout = new RandomAccessFile(filename, "rw ");
content= " <html> <body> "+content+ " </body> </html> ";
fout.writeBytes(content);
fout.close();
}catch(Exception e) {
e.printStackTrace();
}
System.out.println( "All is Over ");
%>
</BODY>
</HTML>
本文转载自 http://www.itjianghu.net/120108/40916358935185219.htm
相关文章推荐
- asp.net中回车提交表单的处理方法 (多按钮处理) [转]
- multipart/form-data post 方法提交表单,后台获取不到数据
- PHP防止表单重复提交的几种常用方法汇总
- JavaScript阻止回车提交表单的方法
- 快捷键提交表单方法汇总
- jquery submit()不能提交表单的解决方法
- jquery中ajax序列化提交form表单的几种方法。
- asp自动生成html文件的方法
- html form表单提交后不刷新不跳转的实现方法------
- jquery实现ajax提交表单的方法总结
- HTML页面禁用Enter键自动提交表单的方法
- form表单提交后不刷新不跳转的实现方法
- Phalcon模板视图页面生成表单提交URL
- 使用JS对form的内容验证失败后阻止提交 &&js校验表单后提交表单的三种方法总结
- form表单提交的几种方法
- jsp中get(URI)方式提交表单的中文乱码解决方法
- 用js将form表单同时提交到两个不同页面的方法
- MVC3.0 提交表单的方法
- jquery实现form表单提交后局部刷新页面的多种方法