List of usage examples for org.apache.commons.fileupload DiskFileUpload DiskFileUpload
public DiskFileUpload()
FileItem
instances. From source file:com.krawler.esp.servlets.deskeramob_V1.java
public static String createUser(Connection conn, HttpServletRequest request, String companyid, String creatorID) throws ServiceException, SessionExpiredException { String status = "failure"; DiskFileUpload fu = new DiskFileUpload(); String userid = UUID.randomUUID().toString(); String pwd = AuthHandler.generateNewPassword(); String newPassSHA1 = AuthHandler.getSHA1(pwd); String username = request.getParameter("username").toString().replaceAll("[\\W]", ""); String fname = request.getParameter("firstname").trim(); String emailid = request.getParameter("email"); emailid = emailid.trim().replace(" ", "+"); if (StringUtil.isNullOrEmpty(username.trim()) || StringUtil.isNullOrEmpty(emailid.trim())) { return "failure"; }//from w w w . j a va2 s. co m if (SignupHandler.useridIsAvailable(conn, username, companyid).equalsIgnoreCase("failure")) { return "failure"; } // if (SignupHandler.(conn, emailid, companyid).equalsIgnoreCase("failure")) { // return "failure"; // } if (StringUtil.isNullOrEmpty(fname)) { fname = username; } PreparedStatement pstmt = null; username = StringUtil.serverHTMLStripper(username); fname = StringUtil.serverHTMLStripper(fname); String lname = StringUtil.serverHTMLStripper(request.getParameter("lastname").toString().trim()); emailid = StringUtil.serverHTMLStripper(emailid); if (StringUtil.isNullOrEmpty(username) || StringUtil.isNullOrEmpty(fname) || StringUtil.isNullOrEmpty(lname) || StringUtil.isNullOrEmpty(emailid)) { status = "failure"; return status; } DbUtil.executeUpdate(conn, "INSERT INTO userlogin(userid, username, password, authkey) values (?, ?, ?, ?)", new Object[] { userid, username, newPassSHA1, pwd }); DbUtil.executeUpdate(conn, "INSERT INTO users (userid, fname, lname, emailid, contactno, address ,image, companyid) " + "VALUES (?,?,?,?,?,?,?,?)", new Object[] { userid, fname, lname, emailid, "", "", "", companyid }); try { String uri = URLUtil.getPageURL(request, com.krawler.esp.web.resource.Links.loginpageFull, CompanyHandler.getCompanySubdomainByCompanyID(conn, companyid)); pstmt = conn.prepareStatement( "select username, fname, lname, emailid from users inner join userlogin on users.userid = userlogin.userid where users.userid = ?"); pstmt.setString(1, creatorID); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { String fnameCreator = rs.getString("fname"); String lnameCreator = rs.getString("lname"); String fullnameCreator = (fnameCreator + " " + lnameCreator).trim(); if (StringUtil.isNullOrEmpty(fnameCreator) && StringUtil.isNullOrEmpty(lnameCreator)) { fullnameCreator = username; } String emailidCreator = rs.getString("emailid"); String pmsg = String.format(KWLErrorMsgs.msgMailInvite, fname, fullnameCreator, username, pwd, uri, fullnameCreator); String companyname = AdminServlet.getCompanyname(conn, companyid); String htmlmsg = String.format(KWLErrorMsgs.msgMailInviteUsernamePassword, fname, fullnameCreator, companyname, username, pwd, uri, uri, fullnameCreator); try { SendMailHandler.postMail(new String[] { emailid }, "[Deskera] Welcome to Deskera", htmlmsg, pmsg, emailidCreator); } catch (ConfigurationException e) { // e.printStackTrace(); } catch (MessagingException e) { // e.printStackTrace(); } status = "{\"success\":true,\"userid\":\"" + userid + "\"}"; } rs.close(); } catch (SQLException e) { throw ServiceException.FAILURE("ProfileHandler.getPersonalInfo", e); } finally { DbPool.closeStatement(pstmt); } return status; }
From source file:com.krawler.esp.servlets.AdminServlet.java
public static String editProject(Connection conn, HttpServletRequest request, String companyid) throws ServiceException { String status = "{\"success\":failure}"; DiskFileUpload fu = new DiskFileUpload(); JSONObject j = new JSONObject(); JSONObject j1 = new JSONObject(); List fileItems = null;// w ww . j a v a2s.c o m try { fileItems = fu.parseRequest(request); } catch (FileUploadException e) { // Logger.getInstance(Admin.class).error(e, e); throw ServiceException.FAILURE("Admin.editProject", e); } HashMap arrParam = new HashMap(); for (Iterator k = fileItems.iterator(); k.hasNext();) { try { FileItem fi1 = (FileItem) k.next(); arrParam.put(fi1.getFieldName(), fi1.getString("UTF-8")); } catch (UnsupportedEncodingException ex) { throw ServiceException.FAILURE("Admin.editProject", ex); } } try { String projectname = StringUtil.serverHTMLStripper(arrParam.get("projectname").toString()); String projectid = StringUtil.serverHTMLStripper(arrParam.get("projectid").toString()); String aboutproject = StringUtil.serverHTMLStripper(arrParam.get("aboutproject").toString()); if (StringUtil.isNullOrEmpty(projectname) || StringUtil.isNullOrEmpty(projectid)) { status = KWLErrorMsgs.rsSuccessFailure; return status; } DbUtil.executeUpdate(conn, "update project set projectname = ?, description = ? where projectid=? and companyid=?", new Object[] { projectname, aboutproject, projectid, companyid }); if (arrParam.get("image").toString().length() != 0) { genericFileUpload uploader = new genericFileUpload(); uploader.doPost(fileItems, arrParam.get("projectid").toString(), StorageHandler.GetProfileImgStorePath()); if (uploader.isUploaded()) { DbUtil.executeUpdate(conn, "update project set image=? where projectid = ? and companyid=?", new Object[] { ProfileImageServlet.ImgBasePath + projectid + "_200" + uploader.getExt(), projectid, companyid }); j.put("image", projectid + "_200" + uploader.getExt()); } } HealthMeterDAO daoHM = new HealthMeterDAOImpl(); daoHM.editBaseLineMeter(conn, projectid, "TASK", arrParam.get("ontime").toString(), arrParam.get("slightly").toString(), arrParam.get("slightly").toString()); Map<String, String> fields = CcUtil.getAllfields(arrParam); CustomColumn cc = CCManager.getCustomColumn(companyid); cc.editColumnsData(conn, fields, projectid); PreparedStatement pstmt = null; pstmt = conn.prepareStatement("select * from project where projectid=? and companyid=?"); pstmt.setString(1, arrParam.get("projectid").toString()); pstmt.setString(2, companyid); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { j.put("projectname", rs.getString("projectname")); j.put("description", rs.getString("description")); j.put("image", rs.getString("image")); } pstmt = conn.prepareStatement( "select count(userid) from projectmembers where projectid = ? and inuseflag = 1"); pstmt.setString(1, arrParam.get("projectid").toString()); rs = pstmt.executeQuery(); if (rs.next()) { j.put("members", rs.getInt(1)); } status = "{\"success\":true,\"data\":" + j.toString() + "}"; String ipAddress = AuthHandler.getIPAddress(request); int auditMode = 0; String loginid = AuthHandler.getUserid(request); String params = AuthHandler.getAuthor(conn, loginid) + " (" + AuthHandler.getUserName(request) + "), "; AuditTrail.insertLog(conn, "323", loginid, projectid, projectid, companyid, params + projectname, ipAddress, auditMode); } catch (SessionExpiredException ex) { Logger.getLogger(AdminServlet.class.getName()).log(Level.SEVERE, null, ex); status = KWLErrorMsgs.rsSuccessFailure; throw ServiceException.FAILURE("Admin.editProject", ex); } catch (JSONException e) { status = KWLErrorMsgs.rsSuccessFailure; throw ServiceException.FAILURE("Admin.editProject", e); } catch (ConfigurationException e) { status = KWLErrorMsgs.rsSuccessFailure; throw ServiceException.FAILURE("Admin.editProject", e); } catch (SQLException e) { status = KWLErrorMsgs.rsSuccessFailure; throw ServiceException.FAILURE("Admin.editProject", e); } return status; }
From source file:com.krawler.workflow.module.dao.ModuleBuilderDaoImpl.java
public String uploadFile(HttpServletRequest request) throws ServiceException { String result = ""; DiskFileUpload fu = new DiskFileUpload(); FileItem fi1 = null;//from ww w . j a v a2 s . c o m List fileItems = null; HashMap<String, String> arrParam = new HashMap<String, String>(); boolean fileUpload = false; ArrayList<FileItem> fi = new ArrayList<FileItem>(); try { parseRequest(request, arrParam, fi, fileUpload); User userObj = (User) get(User.class, sessionHandlerDao.getUserid()); // if(fileUpload){ for (int cnt = 0; cnt < fi.size(); cnt++) { String fileName = new String(fi.get(cnt).getName().getBytes(), "UTF8"); String Ext = ""; if (fileName.contains(".")) { Ext = fileName.substring(fileName.lastIndexOf(".")); } mb_docs docObj = new mb_docs(); docObj.setDocname(fileName); docObj.setUserid(userObj); docObj.setStorename(""); docObj.setDoctype(""); docObj.setUploadedon(new Date()); docObj.setStorageindex(1); // int size = getSize(fi.get(cnt).getSize()); docObj.setDocsize(fi.get(cnt).getSize() + ""); save(docObj); String fileid = docObj.getDocid(); if (Ext.length() > 0) fileid = fileid + Ext; docObj.setStorename(fileid); saveOrUpdate(docObj); String reftable = getReportTableName(arrParam.get("moduleid")); mb_docsmap docmapObj = new mb_docsmap(); docmapObj.setDocid(docObj); docmapObj.setRecid(arrParam.get("recid")); docmapObj.setReftable(reftable); save(docmapObj); uploadFile(fi.get(cnt), PropsValues.STORE_PATH + reftable, fileid); } // } } catch (java.io.UnsupportedEncodingException e) { logger.warn(e.getMessage(), e); throw ServiceException.FAILURE("uploadFile", e); } catch (com.krawler.common.session.SessionExpiredException e) { logger.warn(e.getMessage(), e); throw ServiceException.FAILURE("uploadFile", e); } return result; }
From source file:nextapp.echo2.webcontainer.filetransfer.JakartaCommonsFileUploadProvider.java
/** * @see nextapp.echo2.webcontainer.filetransfer.MultipartUploadSPI#updateComponent(nextapp.echo2.webrender.Connection, * nextapp.echo2.app.filetransfer.UploadSelect) *//*from w ww . j a v a 2 s .c o m*/ public void updateComponent(Connection conn, UploadSelect uploadSelect) throws IOException, ServletException { DiskFileUpload handler = null; HttpServletRequest request = null; List items = null; Iterator it = null; FileItem item = null; boolean searching = true; InputStream in = null; int size = 0; String contentType = null; String name = null; try { handler = new DiskFileUpload(); handler.setSizeMax(getFileUploadSizeLimit()); handler.setSizeThreshold(getMemoryCacheThreshold()); handler.setRepositoryPath(getDiskCacheLocation().getCanonicalPath()); request = conn.getRequest(); items = handler.parseRequest(request); searching = true; it = items.iterator(); while (it.hasNext() && searching) { item = (FileItem) it.next(); if (UploadFormService.FILE_PARAMETER_NAME.equals(item.getFieldName())) { in = item.getInputStream(); size = (int) item.getSize(); contentType = item.getContentType(); name = item.getName(); File tempFile = writeTempFile(in, uploadSelect); UploadEvent uploadEvent = new UploadEvent(tempFile, size, contentType, name); UploadSelectPeer.activateUploadSelect(uploadSelect, uploadEvent); searching = false; } } } catch (FileUploadException e) { throw new IOException(e.getMessage()); } }
From source file:oe.product.fck.common.SimpleUploaderServlet.java
/** * Manage the Upload requests.<br> * * The servlet accepts commands sent in the following format:<br> * simpleUploader?Type=ResourceType<br><br> * It store the file (renaming it in case a file with the same name exists) and then return an HTML file * with a javascript command in it.//from w w w. j av a 2 s. c om * */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (debug) System.out.println("--- BEGIN DOPOST ---"); response.setContentType("text/html; charset=UTF-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = response.getWriter(); String typeStr = request.getParameter("Type"); String currentPath = baseDir + typeStr; String currentDirPath = getServletContext().getRealPath(currentPath); currentPath = request.getContextPath() + currentPath; if (debug) System.out.println(currentDirPath); String retVal = "0"; String newName = ""; String fileUrl = ""; String errorMessage = ""; String $fileName = ""; String fileName = ""; if (enabled) { DiskFileUpload upload = new DiskFileUpload(); try { List items = upload.parseRequest(request); Map fields = new HashMap(); Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) fields.put(item.getFieldName(), item.getString()); else fields.put(item.getFieldName(), item); } FileItem uplFile = (FileItem) fields.get("NewFile"); String fileNameLong = uplFile.getName(); fileNameLong = fileNameLong.replace('\\', '/'); String[] pathParts = fileNameLong.split("/"); fileName = pathParts[pathParts.length - 1]; String nameWithoutExt = getNameWithoutExtension(fileName); fileName = new String(fileName.getBytes("GBK"), "UTF-8"); String ext = getExtension(fileName); $fileName = UUID.randomUUID().toString() + "." + ext; fileUrl = currentPath + "/" + $fileName; File pathToSave = new File(currentDirPath, $fileName); if (extIsAllowed(typeStr, ext)) { int counter = 1; while (pathToSave.exists()) { fileName = fileName + "(" + counter + ")" + "." + ext; newName = fileName; fileUrl = currentPath + "/" + $fileName + "(" + counter + ")" + "." + ext; retVal = "201"; pathToSave = new File(currentDirPath, newName); counter++; } uplFile.write(pathToSave); } else { retVal = "202"; errorMessage = ""; if (debug) System.out.println("Invalid file type: " + ext); } } catch (Exception ex) { if (debug) ex.printStackTrace(); retVal = "203"; } } else { retVal = "1"; errorMessage = "This file uploader is disabled. Please check the WEB-INF/web.xml file"; } out.println("<script type=\"text/javascript\">"); out.println("window.parent.OnUploadCompleted(" + retVal + ",'" + fileUrl + "','" + fileName + "','" + errorMessage + "');"); out.println("</script>"); out.flush(); out.close(); if (debug) System.out.println("--- END DOPOST ---"); }
From source file:org.apache.catalina.manager.HTMLManagerServlet.java
/** * Process a POST request for the specified resource. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet-specified error occurs *//*from w w w . j av a 2 s . c om*/ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Identify the request parameters that we need String command = request.getPathInfo(); if (command == null || !command.equals("/upload")) { doGet(request, response); return; } // Prepare our output writer to generate the response message response.setContentType("text/html; charset=" + Constants.CHARSET); String message = ""; // Create a new file upload handler DiskFileUpload upload = new DiskFileUpload(); // Get the tempdir File tempdir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir"); // Set upload parameters upload.setSizeMax(-1); upload.setRepositoryPath(tempdir.getCanonicalPath()); // Parse the request String basename = null; File appBaseDir = null; String war = null; FileItem warUpload = null; try { List items = upload.parseRequest(request); // Process the uploaded fields Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { if (item.getFieldName().equals("deployWar") && warUpload == null) { warUpload = item; } else { item.delete(); } } } while (true) { if (warUpload == null) { message = sm.getString("htmlManagerServlet.deployUploadNoFile"); break; } war = warUpload.getName(); if (!war.toLowerCase().endsWith(".war")) { message = sm.getString("htmlManagerServlet.deployUploadNotWar", war); break; } // Get the filename if uploaded name includes a path if (war.lastIndexOf('\\') >= 0) { war = war.substring(war.lastIndexOf('\\') + 1); } if (war.lastIndexOf('/') >= 0) { war = war.substring(war.lastIndexOf('/') + 1); } // Identify the appBase of the owning Host of this Context // (if any) String appBase = null; appBase = ((Host) context.getParent()).getAppBase(); appBaseDir = new File(appBase); if (!appBaseDir.isAbsolute()) { appBaseDir = new File(System.getProperty("catalina.base"), appBase); } basename = war.substring(0, war.indexOf(".war")); File file = new File(appBaseDir, war); if (file.exists()) { message = sm.getString("htmlManagerServlet.deployUploadWarExists", war); break; } warUpload.write(file); try { URL url = file.toURL(); war = url.toString(); war = "jar:" + war + "!/"; } catch (MalformedURLException e) { file.delete(); throw e; } break; } } catch (Exception e) { message = sm.getString("htmlManagerServlet.deployUploadFail", e.getMessage()); log(message, e); } finally { if (warUpload != null) { warUpload.delete(); } warUpload = null; } // Extract the nested context deployment file (if any) File localWar = new File(appBaseDir, basename + ".war"); File localXml = new File(configBase, basename + ".xml"); try { extractXml(localWar, localXml); } catch (IOException e) { log("managerServlet.extract[" + localWar + "]", e); return; } String config = null; try { if (localXml.exists()) { URL url = localXml.toURL(); config = url.toString(); } } catch (MalformedURLException e) { throw e; } // If there were no errors, deploy the WAR if (message.length() == 0) { message = deployInternal(config, null, war); } list(request, response, message); }
From source file:org.apache.catalina.servlets.HTMLManagerServlet.java
/** * Process a POST request for the specified resource. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet-specified error occurs *//*from w w w . java 2s. c o m*/ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Identify the request parameters that we need String command = request.getPathInfo(); if (command == null || !command.equals("/upload")) { doGet(request, response); return; } // Prepare our output writer to generate the response message Locale locale = Locale.getDefault(); String charset = context.getCharsetMapper().getCharset(locale); response.setLocale(locale); response.setContentType("text/html; charset=" + charset); String message = ""; // Create a new file upload handler DiskFileUpload upload = new DiskFileUpload(); // Get the tempdir File tempdir = (File) getServletContext().getAttribute("javax.servlet.context.tempdir"); // Set upload parameters upload.setSizeMax(-1); upload.setRepositoryPath(tempdir.getCanonicalPath()); // Parse the request String war = null; FileItem warUpload = null; try { List items = upload.parseRequest(request); // Process the uploaded fields Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { if (item.getFieldName().equals("installWar") && warUpload == null) { warUpload = item; } else { item.delete(); } } } while (true) { if (warUpload == null) { message = sm.getString("htmlManagerServlet.installUploadNoFile"); break; } war = warUpload.getName(); if (!war.toLowerCase().endsWith(".war")) { message = sm.getString("htmlManagerServlet.installUploadNotWar", war); break; } // Get the filename if uploaded name includes a path if (war.lastIndexOf('\\') >= 0) { war = war.substring(war.lastIndexOf('\\') + 1); } if (war.lastIndexOf('/') >= 0) { war = war.substring(war.lastIndexOf('/') + 1); } // Identify the appBase of the owning Host of this Context // (if any) String appBase = null; File appBaseDir = null; appBase = ((Host) context.getParent()).getAppBase(); appBaseDir = new File(appBase); if (!appBaseDir.isAbsolute()) { appBaseDir = new File(System.getProperty("catalina.base"), appBase); } File file = new File(appBaseDir, war); if (file.exists()) { message = sm.getString("htmlManagerServlet.installUploadWarExists", war); break; } warUpload.write(file); try { URL url = file.toURL(); war = url.toString(); war = "jar:" + war + "!/"; } catch (MalformedURLException e) { file.delete(); throw e; } break; } } catch (Exception e) { message = sm.getString("htmlManagerServlet.installUploadFail", e.getMessage()); log(message, e); } finally { if (warUpload != null) { warUpload.delete(); } warUpload = null; } // If there were no errors, install the WAR if (message.length() == 0) { message = install(null, null, war); } list(request, response, message); }
From source file:org.apache.struts.upload.CommonsMultipartRequestHandler.java
/** * <p> Parses the input stream and partitions the parsed items into a set * of form fields and a set of file items. In the process, the parsed * items are translated from Commons FileUpload <code>FileItem</code> * instances to Struts <code>FormFile</code> instances. </p> * * @param request The multipart request to be processed. * @throws ServletException if an unrecoverable error occurs. */// www . j av a2s.c o m public void handleRequest(HttpServletRequest request) throws ServletException { // Get the app config for the current request. ModuleConfig ac = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY); // Create and configure a DIskFileUpload instance. DiskFileUpload upload = new DiskFileUpload(); // The following line is to support an "EncodingFilter" // see http://issues.apache.org/bugzilla/show_bug.cgi?id=23255 upload.setHeaderEncoding(request.getCharacterEncoding()); // Set the maximum size before a FileUploadException will be thrown. upload.setSizeMax(getSizeMax(ac)); // Set the maximum size that will be stored in memory. upload.setSizeThreshold((int) getSizeThreshold(ac)); // Set the the location for saving data on disk. upload.setRepositoryPath(getRepositoryPath(ac)); // Create the hash tables to be populated. elementsText = new Hashtable(); elementsFile = new Hashtable(); elementsAll = new Hashtable(); // Parse the request into file items. List items = null; try { items = upload.parseRequest(request); } catch (DiskFileUpload.SizeLimitExceededException e) { // Special handling for uploads that are too big. request.setAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED, Boolean.TRUE); return; } catch (FileUploadException e) { log.error("Failed to parse multipart request", e); throw new ServletException(e); } // Partition the items into form fields and files. Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { addTextParameter(request, item); } else { addFileParameter(item); } } }
From source file:org.apache.tapestry.multipart.DefaultMultipartDecoder.java
/** * Decodes the request, storing the part map (keyed on query parameter name, * value is {@link IPart} into the request as an attribute. * /* ww w. j a v a 2 s . co m*/ * @throws ApplicationRuntimeException if decode fails, for instance the * request exceeds getMaxSize() * **/ public void decode(HttpServletRequest request) { Map partMap = new HashMap(); request.setAttribute(PART_MAP_ATTRIBUTE_NAME, partMap); // The encoding that will be used to decode the string parameters // It should NOT be null at this point, but it may be // if the older Servlet API 2.2 is used String encoding = request.getCharacterEncoding(); // DiskFileUpload is not quite threadsafe, so we create a new instance // for each request. DiskFileUpload upload = new DiskFileUpload(); List parts = null; try { if (encoding != null) upload.setHeaderEncoding(encoding); parts = upload.parseRequest(request, _thresholdSize, _maxSize, _repositoryPath); } catch (FileUploadException ex) { throw new ApplicationRuntimeException( Tapestry.format("DefaultMultipartDecoder.unable-to-decode", ex.getMessage()), ex); } int count = Tapestry.size(parts); for (int i = 0; i < count; i++) { FileItem uploadItem = (FileItem) parts.get(i); if (uploadItem.isFormField()) { try { String name = uploadItem.getFieldName(); String value; if (encoding == null) value = uploadItem.getString(); else value = uploadItem.getString(encoding); ValuePart valuePart = (ValuePart) partMap.get(name); if (valuePart != null) { valuePart.add(value); } else { valuePart = new ValuePart(value); partMap.put(name, valuePart); } } catch (UnsupportedEncodingException ex) { throw new ApplicationRuntimeException(Tapestry.format("illegal-encoding", encoding), ex); } } else { UploadPart uploadPart = new UploadPart(uploadItem); partMap.put(uploadItem.getFieldName(), uploadPart); } } }
From source file:org.araneaframework.servlet.filter.StandardServletFileUploadFilterService.java
protected void action(Path path, InputData input, OutputData output) throws Exception { HttpServletRequest request = ((ServletInputData) input).getRequest(); if (FileUpload.isMultipartContent(request)) { Map fileItems = new HashMap(); Map parameterLists = new HashMap(); // Create a new file upload handler DiskFileUpload upload = new DiskFileUpload(); if (useRequestEncoding) upload.setHeaderEncoding(request.getCharacterEncoding()); else if (multipartEncoding != null) upload.setHeaderEncoding(multipartEncoding); // Set upload parameters if (maximumCachedSize != null) upload.setSizeThreshold(maximumCachedSize.intValue()); if (maximumSize != null) upload.setSizeMax(maximumSize.longValue()); if (tempDirectory != null) upload.setRepositoryPath(tempDirectory); // Parse the request List items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { fileItems.put(item.getFieldName(), item); } else { List parameterValues = (List) parameterLists.get(item.getFieldName()); if (parameterValues == null) { parameterValues = new ArrayList(); parameterLists.put(item.getFieldName(), parameterValues); }//from w w w. j a v a2s .c o m parameterValues.add(item.getString()); } } log.debug("Parsed multipart request, found '" + fileItems.size() + "' file items and '" + parameterLists.size() + "' request parameters"); output.extend(ServletFileUploadInputExtension.class, new StandardServletFileUploadInputExtension(fileItems)); request = new MultipartWrapper(request, parameterLists); ((ServletOverridableInputData) input).setRequest(request); } super.action(path, input, output); }