List of usage examples for org.apache.commons.fileupload FileItem getInputStream
InputStream getInputStream() throws IOException;
From source file:com.silverpeas.form.displayers.AbstractFileFieldDisplayer.java
protected SimpleDocument createSimpleDocument(String objectId, String componentId, FileItem item, String fileName, String userId, boolean versionned) throws IOException { SimpleDocumentPK documentPk = new SimpleDocumentPK(null, componentId); SimpleAttachment attachment = new SimpleAttachment(fileName, null, null, null, item.getSize(), FileUtil.getMimeType(fileName), userId, new Date(), null); SimpleDocument document;//from w w w . j a v a2s .c o m if (versionned) { document = new HistorisedDocument(documentPk, objectId, 0, attachment); } else { document = new SimpleDocument(documentPk, objectId, 0, false, null, attachment); } document.setDocumentType(DocumentType.form); InputStream in = item.getInputStream(); try { return AttachmentServiceFactory.getAttachmentService().createAttachment(document, in, false); } finally { IOUtils.closeQuietly(in); } }
From source file:hu.sztaki.lpds.pgportal.portlets.credential.AssertionPortlet.java
/** * Checks if the file input field was selected, if the file exists and * if the file is not null. Proper error messages are set, showed on the GUI. * @param type String contains the selected type (p12, pem or saml) * @param f FileItem containing the uploaded file *//* w ww .j ava 2s . co m*/ private void checkFile(String type, FileItem f) throws ResourceNotFoundException, IOException { logger.trace("checkFile"); if ((f == null) || "".equals(f.getName())) { throw new ResourceNotFoundException(type + " file must be selected."); } if (f.getInputStream() == null) { throw new ResourceNotFoundException("Selected " + type + " file does not exist."); } if (f.getInputStream().available() == 0) { throw new ResourceNotFoundException("Selected " + type + " file cannot be accessed."); } }
From source file:mercury.UploadController.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); try {//w ww. j a v a 2 s . c o m List items = upload.parseRequest(request); Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!item.isFormField()) { String targetUrl = Config.getConfigProperty(ConfigurationEnum.DIGITAL_MEDIA); if (StringUtils.isBlank(targetUrl)) { targetUrl = request.getRequestURL().toString(); targetUrl = targetUrl.substring(0, targetUrl.lastIndexOf('/')); } targetUrl += "/DigitalMediaController"; PostMethod filePost = new PostMethod(targetUrl); filePost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false); UploadPartSource src = new UploadPartSource(item.getName(), item.getSize(), item.getInputStream()); Part[] parts = new Part[1]; parts[0] = new FilePart(item.getName(), src, item.getContentType(), null); filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(filePost); if (status == HttpStatus.SC_OK) { String data = filePost.getResponseBodyAsString(); JSONObject json = new JSONObject(data); if (json.has("id")) { JSONObject responseJson = new JSONObject(); responseJson.put("success", true); responseJson.put("id", json.getString("id")); responseJson.put("uri", targetUrl + "?id=" + json.getString("id")); response.getWriter().write(responseJson.toString()); } } filePost.releaseConnection(); return; } } } catch (FileUploadException e) { e.printStackTrace(); } catch (JSONException je) { je.printStackTrace(); } } response.getWriter().write("{success: false}"); }
From source file:au.edu.unimelb.news.servlet.ImportServlet.java
/** * Reads all user input related to creating a new agenda item and creates the agenda item. *///from w w w .j a v a 2s. c om @SuppressWarnings("unchecked") protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = UserHelper.getUser(request); response.setContentType("text/html"); PrintWriter out = new PrintWriter(response.getOutputStream()); LayoutHelper.headerTitled(out, "Import"); LayoutHelper.menubar(out, user); out.println("<div id=\"breadcrumbs\">"); out.println("<a href=\"http://www.unimelb.edu.au\">University home</a> >"); out.println("<a href=\"" + Configuration.appPrefix + "/\">University News</a> >"); out.println("Document Import"); out.println("</div>"); out.println("<div id=\"content\">"); out.println("<h2>Importing</h2>"); //out.flush(); /* * This chunk calls the Jakarta Commons Fileupload component to * process the file upload information. */ FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = null; try { items = upload.parseRequest(request); } catch (Exception e) { out.println("Fatal error: " + e.getMessage()); out.println("</div>"); LayoutHelper.footer(out); out.flush(); out.close(); } /* * Use the Jakarta Commons Fileupload component to read the * field variables. */ try { out.println("<ul>"); String filename = ""; for (FileItem field : items) { if (!field.isFormField()) { filename = field.getName(); if (filename.contains("/")) filename = filename.substring(filename.lastIndexOf('/') + 1); if (filename.contains("\\")) filename = filename.substring(filename.lastIndexOf('\\') + 1); int no = random.nextInt(); if (no < 1) no = -no; if (filename.length() > 0 && field.getSize() > 0 && field.getFieldName().equals("import_file")) { ArticleImport helper = new ArticleImport(new ArticleImportResponder(user, out)); helper.process(field.getInputStream(), user); } } } out.println("</ul>"); } catch (Exception e) { out.println("Fatal error: " + e.getMessage()); out.println("</div>"); LayoutHelper.footer(out); out.flush(); out.close(); } out.println("File upload processing complete."); out.println("</div>"); LayoutHelper.footer(out); out.flush(); out.close(); }
From source file:com.ephesoft.gxt.systemconfig.server.ImportPoolServlet.java
/** * Unzip the attached zipped file.//from w w w. j a v a 2 s .com * * @param req {@link HttpServletRequest} * @param resp {@link HttpServletResponse} * @param batchSchemaService {@link BatchSchemaService} * @throws IOException */ private void attachFile(final HttpServletRequest req, final HttpServletResponse resp, final BatchSchemaService batchSchemaService) throws IOException { final PrintWriter printWriter = resp.getWriter(); File tempZipFile = null; InputStream instream = null; OutputStream out = null; String tempOutputUnZipDir = CoreCommonConstant.EMPTY_STRING; if (ServletFileUpload.isMultipartContent(req)) { final FileItemFactory factory = new DiskFileItemFactory(); final ServletFileUpload upload = new ServletFileUpload(factory); final String exportSerailizationFolderPath = batchSchemaService.getBatchExportFolderLocation(); final File exportSerailizationFolder = new File(exportSerailizationFolderPath); if (!exportSerailizationFolder.exists()) { exportSerailizationFolder.mkdir(); } String zipFileName = CoreCommonConstant.EMPTY_STRING; String zipPathname = CoreCommonConstant.EMPTY_STRING; List<FileItem> items; try { items = upload.parseRequest(req); for (final FileItem item : items) { if (!item.isFormField()) { zipFileName = item.getName(); if (zipFileName != null) { zipFileName = zipFileName.substring(zipFileName.lastIndexOf(File.separator) + 1); } zipPathname = exportSerailizationFolderPath + File.separator + zipFileName; // get only the file name not whole path if (zipFileName != null) { zipFileName = FilenameUtils.getName(zipFileName); } try { instream = item.getInputStream(); tempZipFile = new File(zipPathname); if (tempZipFile.exists()) { tempZipFile.delete(); } out = new FileOutputStream(tempZipFile); final byte buf[] = new byte[1024]; int len; while ((len = instream.read(buf)) > 0) { out.write(buf, 0, len); } } catch (final FileNotFoundException fileNotFoundException) { log.error("Unable to create the export folder." + fileNotFoundException, fileNotFoundException); printWriter.write("Unable to create the export folder.Please try again."); } catch (final IOException ioException) { log.error("Unable to read the file." + ioException, ioException); printWriter.write("Unable to read the file.Please try again."); } finally { if (out != null) { try { out.close(); } catch (final IOException ioException) { log.info("Could not close stream for file." + tempZipFile); } } if (instream != null) { try { instream.close(); } catch (final IOException ioException) { log.info("Could not close stream for file." + zipFileName); } } } } } } catch (final FileUploadException fileUploadException) { log.error("Unable to read the form contents." + fileUploadException, fileUploadException); printWriter.write("Unable to read the form contents. Please try again."); } tempOutputUnZipDir = exportSerailizationFolderPath + File.separator + zipFileName.substring(0, zipFileName.lastIndexOf(CoreCommonConstant.DOT)) + System.nanoTime(); try { FileUtils.unzip(tempZipFile, tempOutputUnZipDir); } catch (final Exception exception) { log.error("Unable to unzip the file." + exception, exception); printWriter.write("Unable to unzip the file. Please try again."); tempZipFile.delete(); } } else { log.error("Request contents type is not supported."); printWriter.write("Request contents type is not supported."); } if (tempZipFile != null) { tempZipFile.delete(); } printWriter.append(SystemConfigSharedConstants.FILE_PATH).append(tempOutputUnZipDir); //printWriter.append("filePath:").append(tempOutputUnZipDir); printWriter.append(CoreCommonConstant.PIPE); printWriter.flush(); }
From source file:com.ephesoft.dcma.gwt.admin.bm.server.ImportBatchClassUploadServlet.java
private void attachFile(HttpServletRequest req, HttpServletResponse resp, BatchSchemaService batchSchemaService, DeploymentService deploymentService, BatchClassService bcService, ImportBatchService imService) throws IOException { PrintWriter printWriter = resp.getWriter(); File tempZipFile = null;// w w w .j a v a2s . c o m InputStream instream = null; OutputStream out = null; String zipWorkFlowName = BatchClassManagementConstants.EMPTY_STRING, tempOutputUnZipDir = BatchClassManagementConstants.EMPTY_STRING, systemFolderPath = BatchClassManagementConstants.EMPTY_STRING; BatchClass importBatchClass = null; if (ServletFileUpload.isMultipartContent(req)) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); String exportSerailizationFolderPath = batchSchemaService.getBatchExportFolderLocation(); File exportSerailizationFolder = new File(exportSerailizationFolderPath); if (!exportSerailizationFolder.exists()) { exportSerailizationFolder.mkdir(); } String zipFileName = BatchClassManagementConstants.EMPTY_STRING; String zipPathname = BatchClassManagementConstants.EMPTY_STRING; List<FileItem> items; try { items = (List<FileItem>) upload.parseRequest(req); for (FileItem item : items) { if (!item.isFormField() && "importFile".equals(item.getFieldName())) { zipFileName = item.getName(); if (zipFileName != null) { zipFileName = zipFileName.substring(zipFileName.lastIndexOf(File.separator) + 1); } zipPathname = exportSerailizationFolderPath + File.separator + zipFileName; if (zipFileName != null) { zipFileName = FilenameUtils.getName(zipFileName); } try { instream = item.getInputStream(); tempZipFile = new File(zipPathname); if (tempZipFile.exists()) { tempZipFile.delete(); } out = new FileOutputStream(tempZipFile); byte buf[] = new byte[BatchClassManagementConstants.BUFFER_SIZE]; int len = instream.read(buf); while ((len) > 0) { out.write(buf, 0, len); len = instream.read(buf); } } catch (FileNotFoundException e) { LOG.error("Unable to create the export folder." + e, e); printWriter.write("Unable to create the export folder.Please try again."); } catch (IOException e) { LOG.error("Unable to read the file." + e, e); printWriter.write("Unable to read the file.Please try again."); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(instream); } } } } catch (FileUploadException e) { LOG.error("Unable to read the form contents." + e, e); printWriter.write("Unable to read the form contents.Please try again."); } tempOutputUnZipDir = exportSerailizationFolderPath + File.separator + zipFileName.substring(0, zipFileName.lastIndexOf('.')); try { FileUtils.unzip(tempZipFile, tempOutputUnZipDir); } catch (Exception e) { LOG.error("Unable to unzip the file." + e, e); printWriter.write("Unable to unzip the file.Please try again."); tempZipFile.delete(); } String serializableFilePath = FileUtils.getFileNameOfTypeFromFolder(tempOutputUnZipDir, SERIALIZATION_EXT); InputStream serializableFileStream = null; try { serializableFileStream = new FileInputStream(serializableFilePath); importBatchClass = (BatchClass) SerializationUtils.deserialize(serializableFileStream); zipWorkFlowName = importBatchClass.getName(); systemFolderPath = importBatchClass.getSystemFolder(); if (systemFolderPath == null) { systemFolderPath = BatchClassManagementConstants.EMPTY_STRING; } } catch (Exception e) { tempZipFile.delete(); LOG.error("Error while importing" + e, e); printWriter.write("Error while importing.Please try again."); } finally { IOUtils.closeQuietly(serializableFileStream); } } else { LOG.error("Request contents type is not supported."); printWriter.write("Request contents type is not supported."); } if (tempZipFile != null) { tempZipFile.delete(); } List<String> uncList = bcService.getAssociatedUNCList(zipWorkFlowName); boolean isWorkflowDeployed = deploymentService.isDeployed(zipWorkFlowName); boolean isWorkflowEqual = imService.isImportWorkflowEqualDeployedWorkflow(importBatchClass, importBatchClass.getName()); printWriterMethod(printWriter, zipWorkFlowName, tempOutputUnZipDir, systemFolderPath, uncList, isWorkflowDeployed, isWorkflowEqual); }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.ShowJspBean.java
/** * Get the poster in the request and write it on the disk. * * @param request/*from ww w . j a va 2s . c om*/ * http request (multipart if contains poster) * @param product * product entity * @return the poster image file (0 : thumbnail, 1 : full size) * @throws BusinessException * the business exception */ private File[] writePoster(HttpServletRequest request, ShowDTO product) throws BusinessException { File[] filePosterArray = null; boolean fileGotten = false; // File uploaded if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; FileItem fileItem = multipartRequest.getFile(PARAMETER_POSTER); if ((fileItem != null) && (fileItem.getSize() > 0)) { InputStream fisPoster = null; try { fisPoster = fileItem.getInputStream(); // File fPoster = new File( new File( posterFolderPath ), // fileItem.getName( ) ); File fPoster = File.createTempFile(FilenameUtils.getBaseName(fileItem.getName()), null); // Generate unique name fPoster = fr.paris.lutece.plugins.stock.utils.FileUtils.getUniqueFile(fPoster); // Store poster picture fr.paris.lutece.plugins.stock.utils.FileUtils.writeInputStreamToFile(fisPoster, fPoster); File fPosterResize = ImageUtils.resizeImage(fPoster, AppPropertiesService.getPropertyInt(PROPERTY_POSTER_MAX_WIDTH, PROPERTY_POSTER_MAX_WIDTH_DEFAULT), AppPropertiesService.getPropertyInt(PROPERTY_POSTER_MAX_HEIGHT, PROPERTY_POSTER_MAX_HEIGHT_DEFAULT), null); // Create a thumbnail image File fTbPoster = ImageUtils.createThumbnail(fPoster, AppPropertiesService.getPropertyInt(PROPERTY_POSTER_THUMB_WIDTH, 120), AppPropertiesService.getPropertyInt(PROPERTY_POSTER_THUMB_HEIGHT, 200)); // Save file name into entity product.setPosterName(fPoster.getName()); fileGotten = true; filePosterArray = new File[] { fTbPoster, fPosterResize }; } catch (IOException e) { throw new BusinessException(product, MESSAGE_ERROR_GET_AFFICHE); } finally { if (fisPoster != null) { try { fisPoster.close(); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } } } } } if (!fileGotten) { // Error mandatory poster if (StringUtils.isEmpty(product.getPosterName())) { throw new BusinessException(product, MESSAGE_ERROR_MANDATORY_POSTER); } } return filePosterArray; }
From source file:com.wwl.utils.Dispatcher.java
/** * Called by the connector servlet to handle a {@code POST} request. In * particular, it handles the {@link Command#FILE_UPLOAD FileUpload} and * {@link Command#QUICK_UPLOAD QuickUpload} commands. * /*from ww w . j a va 2 s. c om*/ * @param request * the current request instance * @return the upload response instance associated with this request */ UploadResponse doPost(final HttpServletRequest request) { logger.debug("Entering Dispatcher#doPost"); Context context = ThreadLocalData.getContext(); context.logBaseParameters(); UploadResponse uploadResponse = null; // check permissions for user actions if (!RequestCycleHandler.isEnabledForFileUpload(request)) uploadResponse = UploadResponse.getFileUploadDisabledError(); // check parameters else if (!Command.isValidForPost(context.getCommandStr())) uploadResponse = UploadResponse.getInvalidCommandError(); else if (!ResourceType.isValidType(context.getTypeStr())) uploadResponse = UploadResponse.getInvalidResourceTypeError(); else if (!UtilsFile.isValidPath(context.getCurrentFolderStr())) uploadResponse = UploadResponse.getInvalidCurrentFolderError(); else { // call the Connector#fileUpload ResourceType type = context.getDefaultResourceType(); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setHeaderEncoding("utf-8"); try { List<FileItem> items = upload.parseRequest(request); // We upload just one file at the same time FileItem uplFile = items.get(0); // Some browsers transfer the entire source path not just the // filename String fileName = FilenameUtils.getName(uplFile.getName()); logger.debug("Parameter NewFile: {}", fileName); // check the extension if (type.isNotAllowedExtension(FilenameUtils.getExtension(fileName))) uploadResponse = UploadResponse.getInvalidFileTypeError(); // Secure image check (can't be done if QuickUpload) else if (type.equals(ResourceType.IMAGE) && PropertiesLoader.isSecureImageUploads() && !UtilsFile.isImage(uplFile.getInputStream())) { uploadResponse = UploadResponse.getInvalidFileTypeError(); } else { //fileName = UUID.randomUUID().toString()+"."+FilenameUtils.getExtension(fileName); fileName = new Date().getTime() + "." + FilenameUtils.getExtension(fileName); String sanitizedFileName = UtilsFile.sanitizeFileName(fileName); logger.debug("Parameter NewFile (sanitized): {}", sanitizedFileName); String newFileName = connector.fileUpload(type, context.getCurrentFolderStr(), sanitizedFileName, uplFile.getInputStream()); String fileUrl = UtilsResponse.fileUrl(RequestCycleHandler.getUserFilesPath(request), type, context.getCurrentFolderStr(), newFileName); if (sanitizedFileName.equals(newFileName)) uploadResponse = UploadResponse.getOK(fileUrl); else { uploadResponse = UploadResponse.getFileRenamedWarning(fileUrl, newFileName); logger.debug("Parameter NewFile (renamed): {}", newFileName); } } uplFile.delete(); } catch (InvalidCurrentFolderException e) { uploadResponse = UploadResponse.getInvalidCurrentFolderError(); } catch (WriteException e) { uploadResponse = UploadResponse.getFileUploadWriteError(); } catch (IOException e) { uploadResponse = UploadResponse.getFileUploadWriteError(); } catch (FileUploadException e) { uploadResponse = UploadResponse.getFileUploadWriteError(); } } logger.debug("Exiting Dispatcher#doPost"); return uploadResponse; }
From source file:fr.paris.lutece.portal.service.csv.CSVReaderService.java
/** * Read a CSV file and call the method/*from w w w.j a v a 2s . c o m*/ * {@link #readLineOfCSVFile(String[], int, Locale, String) * readLineOfCSVFile} for * each of its lines. * @param fileItem FileItem to get the CSV file from. If the creation of the * input stream associated to this file throws a IOException, * then an error is returned and the file is not red. * @param nColumnNumber Number of columns of each lines. Use 0 to skip * column number check (for example if every lines don't have the * same number of columns) * @param bCheckFileBeforeProcessing Indicates if the file should be check * before processing any of its line. If it is set to true, then * then no line is processed if the file has any error. * @param bExitOnError Indicates if the processing of the CSV file should * end on the first error, or at the end of the file. * @param bSkipFirstLine Indicates if the first line of the file should be * skipped or not. * @param locale the locale * @param strBaseUrl The base URL * @return Returns the list of errors that occurred during the processing of * the file. The returned list is sorted * @see CSVMessageDescriptor#compareTo(CSVMessageDescriptor) * CSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information * about sort */ public List<CSVMessageDescriptor> readCSVFile(FileItem fileItem, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl) { if (fileItem != null) { InputStreamReader inputStreamReader = null; try { inputStreamReader = new InputStreamReader(fileItem.getInputStream()); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } if (inputStreamReader != null) { CSVReader csvReader = new CSVReader(inputStreamReader, getCSVSeparator(), getCSVEscapeCharacter()); return readCSVFile(inputStreamReader, csvReader, nColumnNumber, bCheckFileBeforeProcessing, bExitOnError, bSkipFirstLine, locale, strBaseUrl); } } List<CSVMessageDescriptor> listErrors = new ArrayList<CSVMessageDescriptor>(); CSVMessageDescriptor errorDescription = new CSVMessageDescriptor(CSVMessageLevel.ERROR, 0, I18nService.getLocalizedString(MESSAGE_NO_FILE_FOUND, locale)); listErrors.add(errorDescription); return listErrors; }
From source file:gov.nih.nci.evs.browser.servlet.UploadServlet.java
/** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs *//*from w w w. j av a 2 s .c o m*/ public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Determine request by attributes String action = (String) request.getParameter("action"); String type = (String) request.getParameter("type"); System.out.println("(*) UploadServlet ...action " + action); if (action == null) { action = "upload_data"; } DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(); /* *Set the size threshold, above which content will be stored on disk. */ fileItemFactory.setSizeThreshold(1 * 1024 * 1024); //1 MB /* * Set the temporary directory to store the uploaded files of size above threshold. */ //fileItemFactory.setRepository(tmpDir); ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory); try { /* * Parse the request */ List items = uploadHandler.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); /* * Handle Form Fields. */ if (item.isFormField()) { System.out.println("File Name = " + item.getFieldName() + ", Value = " + item.getString()); //String s = convertStreamToString(item.getInputStream(), item.getSize()); //System.out.println(s); } else { //Handle Uploaded files. System.out.println("Field Name = " + item.getFieldName() + ", File Name = " + item.getName() + ", Content type = " + item.getContentType() + ", File Size = " + item.getSize()); String s = convertStreamToString(item.getInputStream(), item.getSize()); //System.out.println(s); request.getSession().setAttribute("action", action); if (action.compareTo("upload_data") == 0) { request.getSession().setAttribute("codes", s); } else { Mapping mapping = new Mapping().toMapping(s); System.out.println("Mapping " + mapping.getMappingName() + " uploaded."); System.out.println("Mapping version: " + mapping.getMappingVersion()); MappingObject obj = mapping.toMappingObject(); HashMap mappings = (HashMap) request.getSession().getAttribute("mappings"); if (mappings == null) { mappings = new HashMap(); } mappings.put(obj.getKey(), obj); request.getSession().setAttribute("mappings", mappings); } } } } catch (FileUploadException ex) { log("Error encountered while parsing the request", ex); } catch (Exception ex) { log("Error encountered while uploading file", ex); } //long ms = System.currentTimeMillis(); if (action.compareTo("upload_data") == 0) { if (type.compareTo("codingscheme") == 0) { response.sendRedirect( response.encodeRedirectURL(request.getContextPath() + "/pages/codingscheme_data.jsf")); } else if (type.compareTo("ncimeta") == 0) { response.sendRedirect( response.encodeRedirectURL(request.getContextPath() + "/pages/ncimeta_data.jsf")); } else if (type.compareTo("valueset") == 0) { response.sendRedirect( response.encodeRedirectURL(request.getContextPath() + "/pages/valueset_data.jsf")); } } else { response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/pages/home.jsf")); } }