日期:2014-05-17 浏览次数:20581 次
<html> <body> <form name = "form1" method = "post" action = "test.jsp "> <textarea name= "t1 "> </textarea> <input type = "submit" name = "Submit" value ="Submit "> </form> </body> </html>
<%@ 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>