1、test.html
Java代码  

文本格式 复制代码 打印 ?
  1.     
  2.      
  3. "form1" method = "post" action = "test.jsp ">     
  4.     "t1 ">      
  5.     "submit" name = "Submit" value ="Submit ">     
  6.      
  7.     
  8.   

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.      
  5.      
  6.  Deal it      
  7. "Content-Type" content = "text/html;charset=gb2312 ">     
  8.      
  9.      
  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= "   "+content+ "   ";     
  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.     
  37.    

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