D:\JavaFrameworks\InsuranceFramework\src\java\servlet\DocumentServletUpload.java
  1 /*
  2  * To change this template, choose Tools | Templates
  3  * and open the template in the editor.
  4  */
  5 
  6 package servlet;
  7 
  8 /**
  9  *
 10  * @author sameldin
 11  */
 12 import java.io.IOException;
 13 import java.io.PrintWriter;
 14 import java.util.Enumeration;
 15 
 16 import javax.servlet.ServletConfig;
 17 import javax.servlet.ServletException;
 18 import javax.servlet.http.HttpServlet;
 19 import javax.servlet.http.HttpServletRequest;
 20 import javax.servlet.http.HttpServletResponse;
 21 
 22 // import com.jspsmart.upload.SmartUpload;
 23 
 24 import utils.*;
 25 import constants.*;
 26 
 27 
 28 public class DocumentServletUpload extends HttpServlet
 29 {
 30 //
 31 //      private ServletConfig config;
 32 //      /**
 33 //      * Init the servlet
 34 //      */
 35 //      final public void init(ServletConfig config) throws ServletException {
 36 //              this.config = config;
 37 //      }
 38 //
 39 //      final public ServletConfig getServletConfig() {
 40 //              return config;
 41 //      }
 42 //      /**
 43 //      * Handles GET requests
 44 //      */
 45 //      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 46 //
 47 //              PrintWriter out = response.getWriter();
 48 //              out.println("<HTML>");
 49 //              out.println("<BODY BGCOLOR='white'>");
 50 //              out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
 51 //              out.println("<HR><BR>");
 52 //              out.println("The method of the HTML form must be POST.");
 53 //              out.println("</BODY>");
 54 //              out.println("</HTML>");
 55 //      }
 56 //
 57 //      /**
 58 //      * Handles POST requests
 59 //      */
 60 //      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 61 //
 62 //              PrintWriter out = response.getWriter();
 63 //              out.println("<HTML>");
 64 //              out.println("<BODY BGCOLOR='white'>");
 65 //              out.println("<H1>Administration Menu: Documents Upload</H1>");
 66 //              out.println("<HR>");
 67 //
 68 //              com.jspsmart.upload.Request myRequest = null;
 69 //              com.jspsmart.upload.File myFile=null;
 70 //              try
 71 //              {
 72 //                      SmartUpload mySmartUpload = new SmartUpload();
 73 //                      mySmartUpload.initialize(config,request,response);
 74 //                      mySmartUpload.setTotalMaxFileSize(0);
 75 //                      mySmartUpload.upload();
 76 //                      myRequest = mySmartUpload.getRequest();
 77 //
 78 ////                    Enumeration objEnum = myRequest.getParameterNames();
 79 ////                    while(myRequest.getParameterNames().hasMoreElements())
 80 ////                    {
 81 ////                            String paramName = (String)objEnum.nextElement();
 82 ////                            Object paramValue = (Object)myRequest.getParameter(paramName);
 83 ////                    }//while
 84 //                      String folderID = "";
 85 //                      String fileAbsolutePath = Constants.ARCHIVE_PATH;
 86 //                      if(myRequest.getParameter(Constants.UPLOAD_2_FOLDER_ID_FIELD) !=null)
 87 //                      {
 88 //                              folderID = (String)myRequest.getParameter(Constants.UPLOAD_2_FOLDER_ID_FIELD);
 89 //                              fileAbsolutePath = FilePathutil.getPath(folderID);
 90 //                      }
 91 //                      out.println(" Traget Folder :" + fileAbsolutePath + "<br><br>");
 92 //
 93 //                      for (int i=0;i<mySmartUpload.getFiles().getCount(); i++)
 94 //                      {
 95 //                              myFile = mySmartUpload.getFiles().getFile(i);
 96 //                              String tempName = myFile.getFileName();
 97 //                              if (!myFile.isMissing())
 98 //                              {
 99 //                                      int intFileSize = Integer.parseInt(String.valueOf(myFile.getSize()));
100 //                                      if (intFileSize <= 0)
101 //                                              continue;
102 //
103 //                                      switch(i)
104 //                                      {
105 //                                              case 0:
106 //                                                      myFile.saveAs(fileAbsolutePath + "/" + tempName, mySmartUpload.SAVE_PHYSICAL);
107 //                                                      out.println(tempName + " file is uploaded successfully.<br>");
108 //                                              break;
109 //                                              case 1:
110 //                                                      myFile.saveAs(fileAbsolutePath + "/" + tempName, mySmartUpload.SAVE_PHYSICAL);
111 //                                                      out.println(tempName + " file is uploaded successfully.<br>");
112 //                                              break;
113 //                                              case 2:
114 //                                                      myFile.saveAs(fileAbsolutePath + "/" + tempName, mySmartUpload.SAVE_PHYSICAL);
115 //                                                      out.println(tempName + " file is uploaded successfully.<br>");
116 //                                              break;
117 //                                              case 3:
118 //                                                      myFile.saveAs(fileAbsolutePath + "/" + tempName, mySmartUpload.SAVE_PHYSICAL);
119 //                                                      out.println(tempName + " file is uploaded successfully.<br>");
120 //                                              break;
121 //                                              case 4:
122 //                                                      myFile.saveAs(fileAbsolutePath + "/" + tempName, mySmartUpload.SAVE_PHYSICAL);
123 //                                                      out.println(tempName + " file is uploaded successfully.<br>");
124 //                                              break;
125 //                                              default:
126 //
127 //                                      }
128 //
129 //                              }//if
130 //                      }//for
131 //              } catch (Exception e){
132 //                      out.println("Unable to upload the file.<br>");
133 //                      out.println("Error : " + e.toString());
134 //              }
135 //
136 //              out.println("</BODY>");
137 //              out.println("</HTML>");
138 //              out.flush();
139 //              out.close();
140 //          }
141 //      /**
142 //      * Destroy the servlet
143 //      */
144 //      public void  destroy () {
145 //      }
146 //
147 }
148 
149