1、test.html
Java代码  

  1. <html>    
  2. <body>     
  3. <form name = "form1" method = "post" action = "test.jsp ">     
  4.     <textarea name= "t1 "> </textarea>     
  5.     <input type = "submit" name = "Submit" value ="Submit ">     
  6. </form>     
  7. </body>    
  8. </html>  

2、test.jsp


Java代码  


  1. <%@   page   contentType = "text/html;   charset=GB2312 "   language= "java "   %>     
  2. <%@   page   import"java.util.*,java.text.* "%>     
  3. <%@   page   import"java.io.* "%>     
  4. <html>     
  5. <head>     
  6. <title> Deal it </title>     
  7. <meta http-equiv = "Content-Type" content = "text/html;charset=gb2312 ">     
  8. </HEAD>     
  9. <BODY>     
  10. <%       
  11.         String content=request.getParameter( "t1 ");     
  12. if(content==null || content.equals( " "))     
  13.       return;     
  14. SimpleDateFormat sdf=new SimpleDateFormat( "yyyyMMdd ");     
  15. java.util.Date rightNow = new java.util.Date();     
  16. String tmp=sdf.format(rightNow);     
  17. System.out.println(tmp);     
  18. String filename=request.getRealPath( "/ ")+tmp+ ".html ";     
  19. System.out.println(filename);     
  20. try {     
  21.             File theFile=new File(filename);     
  22.             if (theFile.exists() == true)   {     
  23.                 theFile.delete();     
  24.             }     
  25.             theFile.createNewFile();     
  26.             RandomAccessFile fout = new RandomAccessFile(filename, "rw ");     
  27.     content= " <html> <body> "+content+ " </body> </html> ";     
  28.             fout.writeBytes(content);     
  29.             fout.close();     
  30.         }catch(Exception e) {     
  31.             e.printStackTrace();     
  32.         }     
  33. System.out.println( "All is Over ");     
  34. %>     
  35.     
  36. </BODY>    
  37. </HTML>   

本文转载自 http://www.itjianghu.net/120108/40916358935185219.htm