<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% @ page import = "java.util. *"%> <% @ page import = "java.sql. *"%> <% @ Page Import = "java.io. *"%> <% @ page import = "org.apache.commons.fileUpload. *"%> <% @ page import = "java.text. *"%> <% @ PAGE Import = "javax.servlet. *, javax.servlet.http. *"%>
Fu.setSizTHRESHOLD (4096); // Set buffer size.
Fu.SetRepositoryPath (Dir "/ Ball / news / images"); // Set the temporary directory. List fileItems = fu.parsequest (request); // parsing the request, returns a collection.
Iterator i = fileItems.iterator (); string fieldvalue = ""; string ff = "; string picname =" false "; object tt ="; vector v = new vector (); while (I.hasNext ()) {FileItem Fi = (fileItem) i.next (); if (FI.isformField ()) // This is used to determine if the file properties, {string fieldName = fi.getfieldName (); // Here you get the form of FieldValue = FI.GETSTRING (); // Some of the form value v.addelement (FIELDVALUE);} else // Here you start the external system file {file fullfile = new file (fi.getname ()); ff = fullfile.getname () ; String rr = ""; java.util.Date date2 = new java.util.Date (); SimpleDateFormat formatter = new SimpleDateFormat ( "yyyyMMddHHmmss"); // get time String str2 = formatter.format (date2); StringTokenizer st = New StringTokenizer (ff, "); if (st.hasmoretokens ()) {string test12 = st.nextToken (); rr = st.nextToken (); //system.out.println (RR);} (Rr.Equals ("") &&! r.equals ("gif") &&! rr.equals ("jpg") &&! rr.equals ("jpeg") {picname = "false";} else {Picname = STR2 "." rr; // Take time for image name
File SavedFile = New file (GetServletContext (). GetRealPath ("/ ball / news / images /"), picname); FI.WRITE (SavedFile); // upload to server} //system.out.println("picname- ----------------------- " picname);} //system.out.println ("v ----------- ------------- " v);} String [] flag = {"
Java.util.date strdate1 = new java.util.date (); string strdate = strdate1.tolocalestring (); // news release time // string newtype = "0"; conn.opendb (); string sql = "SELECT TOP 5 * from b_news where newtype = " newtype " ORDER BY ID DESC "; string straTemp ="
String filePath = ""; filePath = request.getRealPath ( "// ball // news // pnews.template"); String templateContent = null; try {templateContent = ReadTemplates.getTlpContent (filePath); System.out.println (templateContent );} Catch (exception e) {system.out.println ("Error to Template!");} // Replace the content in the template //system.out.println ("PICNAME --------- ----------------------- " picname"; TemplateContent = ReplaceAll.replace (TemplateContent, Flag [0], Title); TensLateContent = ReplaceAll.replace templateContent, flag [1], strDate); // templateContent = ReplaceAll.replace (templateContent, flag [2], editer); templateContent = ReplaceAll.replace (templateContent, flag [3], content); templateContent = ReplaceAll.replace ( TemplateContent, Flag [4], Strtemp; TemplateContent = ReplaceallAll.Replace (TemplateContent, Flag [5], Picname);
// According to the time file name and path name Calendar Calendar = Calendar.GetInstance (); string filename = String.Valueof (Calendar.gettimeinmillis ()) ". Html"; string pathname = Request.getRealPath ("ball / news" ) "//" Calendar.get (Calendar.Year) "//" (Calendar.Mont) 1) "//" Calendar.Get (Calendar.day_Of_Month) "/ / "; String Url = Calendar.get (Calendar.Year) " / " (Calendar.Get (Calendar.mont) 1) " / " Calendar.get (Calendar.day_Of_Month) " / "; URL = filename; //system.out.println (URL); Try {Writehtml.save (Templatecontent, Pathname, FileName);} catch (Exception E) {system.out.println ("Error to HTML! ------ ------- " E.getMessage ());