List of usage examples for org.apache.commons.fileupload FileItem getInputStream
InputStream getInputStream() throws IOException;
From source file:com.zhoujian.fckeditor.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 w w w . j ava2s. co m*/ * @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.isFileUploadEnabled(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.isDeniedExtension(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 { 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); } } // if (uplFile.getSize() > 1024 * 500) { uploadResponse = new UploadResponse(204); } 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:com.sr.model.dao.IMahasiswaDAOImpl.java
@Override public boolean insertBiodata(Mahasiswa mhs, AkademikSR aka, FileItem foto, List<Prestasi> prestasi) { try {/* ww w .jav a 2s . c om*/ LobHandler lobHandler = new DefaultLobHandler(); getJdbcTemplate().update(INSERT_BIODATA, new Object[] { mhs.getNamaMhs(), mhs.getTempat_lahir(), mhs.getTanggal_lahir(), mhs.getAgama(), mhs.getKelamin(), mhs.getAlamat_asal(), mhs.getKab_kota_asal(), mhs.getProv_asal(), mhs.getNo_hp_mhs(), mhs.getNama_ayah(), mhs.getNama_ibu(), mhs.getPendidikan_ayah(), mhs.getPendidikan_ibu(), mhs.getPekerjaan_ayah(), mhs.getPekerjaan_ibu(), mhs.getPendapatan_ortu(), mhs.getNo_tel_ortu(), mhs.getNo_hp_ortu(), mhs.getAlamat_keluarga(), mhs.getNo_tel_keluarga(), mhs.getNo_hp_keluarga(), new SqlLobValue(foto.getInputStream(), (int) foto.getSize(), lobHandler), mhs.getNim() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR }); getJdbcTemplate().update(INSERT_AKADEMIK, new Object[] { aka.getProdi(), aka.getIpk_masuk(), aka.getSemester(), aka.getRapor_smu(), aka.getJurusan(), aka.getFakultas(), aka.getNim() }, new int[] { Types.VARCHAR, Types.DECIMAL, Types.NUMERIC, Types.DECIMAL, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); for (Prestasi pres : prestasi) { getJdbcTemplate().update(INSERT_PRESTASI, new Object[] { pres.getNo_sertifikat(), pres.getNim(), pres.getNama_prestasi(), pres.getJenis_prestasi() }); } return true; } catch (DataAccessException da) { System.out.println("DataAccessException" + da.getMessage()); } catch (FileNotFoundException ex) { System.out.println("FileNotFoundException " + ex.getMessage()); } catch (IOException ex) { System.out.println(ex.getMessage()); } return false; }
From source file:com.ikon.servlet.admin.ReportServlet.java
@SuppressWarnings("unchecked") public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doPost({}, {})", request, response); request.setCharacterEncoding("UTF-8"); String action = ""; String userId = request.getRemoteUser(); updateSessionManager(request);//from w w w . jav a2 s . c o m try { if (ServletFileUpload.isMultipartContent(request)) { InputStream is = null; FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); Report rp = new Report(); for (Iterator<FileItem> it = items.iterator(); it.hasNext();) { FileItem item = it.next(); if (item.isFormField()) { if (item.getFieldName().equals("action")) { action = item.getString("UTF-8"); } else if (item.getFieldName().equals("rp_id")) { rp.setId(Integer.parseInt(item.getString("UTF-8"))); } else if (item.getFieldName().equals("rp_name")) { rp.setName(item.getString("UTF-8")); } else if (item.getFieldName().equals("rp_active")) { rp.setActive(true); } } else { is = item.getInputStream(); rp.setFileName(FilenameUtils.getName(item.getName())); rp.setFileMime(MimeTypeConfig.mimeTypes.getContentType(item.getName())); rp.setFileContent(SecureStore.b64Encode(IOUtils.toByteArray(is))); is.close(); } } if (action.equals("create")) { long id = ReportDAO.create(rp); // Activity log UserActivity.log(userId, "ADMIN_REPORT_CREATE", Long.toString(id), null, rp.toString()); list(userId, request, response); } else if (action.equals("edit")) { Report tmp = ReportDAO.findByPk(rp.getId()); tmp.setActive(rp.isActive()); tmp.setFileContent(rp.getFileContent()); tmp.setFileMime(rp.getFileMime()); tmp.setFileName(rp.getFileName()); tmp.setName(rp.getName()); ReportDAO.update(tmp); // Activity log UserActivity.log(userId, "ADMIN_REPORT_EDIT", Long.toString(rp.getId()), null, rp.toString()); list(userId, request, response); } else if (action.equals("delete")) { ReportDAO.delete(rp.getId()); // Activity log UserActivity.log(userId, "ADMIN_REPORT_DELETE", Long.toString(rp.getId()), null, null); list(userId, request, response); } } } catch (DatabaseException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } catch (FileUploadException e) { log.error(e.getMessage(), e); sendErrorRedirect(request, response, e); } }
From source file:fsi_admin.JAwsS3Conn.java
@SuppressWarnings("rawtypes") private boolean subirArchivo(StringBuffer msj, AmazonS3 s3, String S3BUKT, String nombre, Vector archivos) { //System.out.println("AwsConn SubirArchivo:" + nombre + ":nombre"); if (!archivos.isEmpty()) { FileItem actual = null; try {/*w ww . j ava 2 s . c o m*/ for (int i = 0; i < archivos.size(); i++) { InputStream inputStream = null; try { actual = (FileItem) archivos.elementAt(i); ///////////////////////////////////////////////////////// //Obtain the Content length of the Input stream for S3 header InputStream is = actual.getInputStream(); byte[] contentBytes = IOUtils.toByteArray(is); Long contentLength = Long.valueOf(contentBytes.length); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(contentLength); //Reobtain the tmp uploaded file as input stream inputStream = actual.getInputStream(); //Put the object in S3 //System.out.println("BUCKET: " + S3BUKT + " OBJETO: " + nombre.replace('_', '-')); //System.out.println("BUCKET: " + S3BUKT + " OBJETO: " + nombre.replace('_', '-')); s3.putObject(new PutObjectRequest(S3BUKT, nombre, inputStream, metadata)); } finally { if (inputStream != null) try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } //////////////////////////////////////////////////////////// } return true; } catch (AmazonServiceException ase) { ase.printStackTrace(); msj.append("Error de AmazonServiceException al subir archivo a S3.<br>"); msj.append("Mensaje: " + ase.getMessage() + "<br>"); msj.append("Cdigo de Estatus HTTP: " + ase.getStatusCode() + "<br>"); msj.append("Cdigo de Error AWS: " + ase.getErrorCode() + "<br>"); msj.append("Tipo de Error: " + ase.getErrorType() + "<br>"); msj.append("Request ID: " + ase.getRequestId()); return false; } catch (AmazonClientException ace) { ace.printStackTrace(); msj.append("Error de AmazonClientException al subir archivo a S3.<br>"); msj.append("Mensaje: " + ace.getMessage()); return false; } catch (IOException e) { e.printStackTrace(); msj.append("Error de Entrada/Salida al subir archivo a S3: " + e.getMessage()); return false; } } else { msj.append("Error al subir archivo a la nube: No se envi ningun archivo"); return false; } }
From source file:com.patrolpro.servlet.UploadJasperReportServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j av a2s . com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); String companyId = request.getParameter("companyId"); FileItem fileData = null; Integer mobileFormId = null; List<FileItem> fields = upload.parseRequest(request); for (int f = 0; f < fields.size(); f++) { if (fields.get(f).getFieldName().equals("file_data")) { fileData = fields.get(f); } else if (fields.get(f).getFieldName().equals("mobileFormId")) { mobileFormId = Integer.parseInt(fields.get(f).getString()); } } if (fileData == null || !fileData.getName().endsWith(".jrxml")) { out.write("{\"error\": \"Invalid file type! Please select a jrxml (Jasper Report) file!\"}"); out.flush(); } else { InputStream iStream = fileData.getInputStream(); MobileFormService mobileService = new MobileFormService(companyId); ByteArrayOutputStream bOutput = new ByteArrayOutputStream(); byte[] buffer = new byte[2048]; int bufCount = 0; while ((bufCount = iStream.read(buffer)) > -1) { bOutput.write(buffer, 0, bufCount); } bOutput.flush(); byte[] rawData = bOutput.toByteArray(); JasperReport jasperReport = JasperCompileManager.compileReport(new ByteArrayInputStream(rawData)); JRParameter[] params = jasperReport.getParameters(); HashMap<String, Class> reportParams = new HashMap<String, Class>(); for (int p = 0; p < params.length; p++) { JRParameter param = params[p]; int searchPos = -1; for (int a = 0; a < MobileForms.getReservedIdentifiers().length; a++) { if (MobileForms.getReservedIdentifiers()[a].equals(param.getName())) { searchPos = a; } } if (!param.isSystemDefined() && searchPos < 0 && !param.getName().startsWith("nfc_l_") && !param.getName().endsWith("_loc")) { reportParams.put(param.getName(), param.getValueClass()); } } ByteArrayOutputStream oStream = new ByteArrayOutputStream(); JasperCompileManager.writeReportToXmlStream(jasperReport, oStream); //JasperCompileManager.compileReportToStream(new ByteArrayInputStream(rawData), oStream); MobileForms selectedForm = mobileService.getForm(mobileFormId); selectedForm.setReportData(oStream.toByteArray()); mobileService.saveForm(selectedForm); Iterator<String> keyIterator = reportParams.keySet().iterator(); ArrayList<MobileFormData> currData = mobileService.getFormData(selectedForm.getMobileFormsId()); int numberInserted = 1; while (keyIterator.hasNext()) { String key = keyIterator.next(); boolean hasData = false; for (int d = 0; d < currData.size(); d++) { if (currData.get(d).getDataLabel().equals(key) && currData.get(d).getActive()) { hasData = true; } } if (!hasData) { MobileFormData formData = new MobileFormData(); formData.setActive(true); formData.setMobileFormsId(selectedForm.getMobileFormsId()); formData.setDataLabel(key); if (reportParams.get(key) == Date.class) { formData.setDateType(5); } else if (reportParams.get(key) == InputStream.class) { formData.setDateType(8); } else if (reportParams.get(key) == Boolean.class) { formData.setDateType(3); } else { formData.setDateType(1); } formData.setOrdering(currData.size() + numberInserted); mobileService.saveFormData(formData); numberInserted++; } } out.write("{}"); out.flush(); } } catch (JRException jr) { out.write("{\"error\": \"" + jr.getMessage().replaceAll("\n", "").replaceAll(":", "").replaceAll("\t", "") + "\"}"); out.flush(); } catch (Exception e) { out.write("{\"error\": \"Exception uploading report, " + e + "\"}"); out.flush(); } finally { out.close(); } }
From source file:com.stratelia.silverpeas.infoLetter.control.InfoLetterSessionController.java
/** * Import Csv emails/*w w w .ja va 2 s . co m*/ * * @param filePart * @throws UtilTrappedException * @throws InfoLetterPeasTrappedException * @throws InfoLetterException */ public void importCsvEmails(FileItem filePart) throws UtilTrappedException, InfoLetterPeasTrappedException, InfoLetterException { InputStream is; try { is = filePart.getInputStream(); } catch (IOException e) { InfoLetterPeasTrappedException ie = new InfoLetterPeasTrappedException( "InfoLetterSessionController.importCsvEmails", SilverpeasException.ERROR, "infoLetter.EX_CSV_FILE", e); ie.setGoBackPage("Emails"); throw ie; } CSVReader csvReader = new CSVReader(getLanguage()); csvReader.initCSVFormat("org.silverpeas.infoLetter.settings.usersCSVFormat", "User", ";"); Variant[][] csvValues; try { csvValues = csvReader.parseStream(is); } catch (UtilTrappedException ute) { ute.setGoBackPage("Emails"); throw ute; } StringBuilder listErrors = new StringBuilder(""); String email; for (int i = 0; i < csvValues.length; i++) { // email email = csvValues[i][0].getValueString(); if (email.length() == 0) {// champ obligatoire listErrors.append(getString("GML.ligne")).append(" = ").append(Integer.toString(i + 1)) .append(", "); listErrors.append(getString("GML.colonne")).append(" = 1, "); listErrors.append(getString("GML.valeur")).append(" = ").append(email).append(", "); listErrors.append(getString("GML.obligatoire")).append("<BR>"); } else if (email.length() > 100) {// verifier 100 char max listErrors.append(getString("GML.ligne")).append(" = ").append(Integer.toString(i + 1)) .append(", "); listErrors.append(getString("GML.colonne")).append(" = 1, "); listErrors.append(getString("GML.valeur")).append(" = ").append(email).append(", "); listErrors.append(getString("GML.nbCarMax")).append(" 100 ").append(getString("GML.caracteres")) .append("<BR>"); } } if (listErrors.length() > 0) { InfoLetterPeasTrappedException ie = new InfoLetterPeasTrappedException( "InfoLetterSessionController.importCsvEmails", SilverpeasException.ERROR, "infoLetter.EX_CSV_FILE", listErrors.toString()); ie.setGoBackPage("Emails"); throw ie; } // pas d'erreur, on importe les emails List<String> emails = new ArrayList<String>(); for (final Variant[] csvValue : csvValues) { // Email email = csvValue[0].getValueString(); emails.add(email); } // suppression des doublons de la liste tout en gardant l'ordre Set<String> setEmails = new LinkedHashSet<String>(emails); emails.clear(); emails.addAll(setEmails); dataInterface.setExternalsSuscribers(this.getCurrentLetter().getPK(), emails); }
From source file:de.jwi.jfm.Folder.java
public void upload(FileItem item, boolean unzip) throws Exception { String name = item.getName(); name = name.replaceAll("\\\\", "/"); int p = name.lastIndexOf('/'); if (p > -1) { name = name.substring(p);// ww w . j a v a 2 s . com } if (unzip) { InputStream is = item.getInputStream(); Unzipper.unzip(is, myFile); } else { File f = new File(myFile, name); item.write(f); } }
From source file:com.ckfinder.connector.handlers.command.FileUploadCommand.java
/** * saves temporary file in the correct file path. * * @param path path to save file/* w w w. j a va 2 s . co m*/ * @param item file upload item * @return result of saving, true if saved correctly * @throws Exception when error occurs. */ private boolean saveTemporaryFile(final String path, final FileItem item) throws Exception { File file = new File(path, this.newFileName); AfterFileUploadEventArgs args = new AfterFileUploadEventArgs(); args.setCurrentFolder(this.currentFolder); args.setFile(file); args.setFileContent(item.get()); if (!ImageUtils.isImage(file)) { item.write(file); if (configuration.getEvents() != null) { configuration.getEvents().run(EventTypes.AfterFileUpload, args, configuration); } return true; } else if (ImageUtils.checkImageSize(item.getInputStream(), this.configuration)) { ImageUtils.createTmpThumb(item.getInputStream(), file, getFileItemName(item), this.configuration); if (configuration.getEvents() != null) { configuration.getEvents().run(EventTypes.AfterFileUpload, args, configuration); } return true; } else if (configuration.checkSizeAfterScaling()) { ImageUtils.createTmpThumb(item.getInputStream(), file, getFileItemName(item), this.configuration); if (FileUtils.checkFileSize(configuration.getTypes().get(this.type), file.length())) { if (configuration.getEvents() != null) { configuration.getEvents().run(EventTypes.AfterFileUpload, args, configuration); } return true; } else { file.delete(); this.errorCode = Constants.Errors.CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG; return false; } } //should be unreacheable return false; }
From source file:dk.dma.msinm.common.repo.RepositoryService.java
/** * Handles upload of files/*from w ww . j a v a 2 s . c o m*/ * * @param path the folder to upload to * @param request the request */ @POST @javax.ws.rs.Path("/upload/{folder:.+}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces("application/json;charset=UTF-8") @RolesAllowed({ "editor" }) public List<String> uploadFile(@PathParam("folder") String path, @Context HttpServletRequest request) throws FileUploadException, IOException { Path folder = repoRoot.resolve(path); if (Files.exists(folder) && !Files.isDirectory(folder)) { log.warn("Failed streaming file to folder: " + folder); throw new WebApplicationException("Invalid upload folder: " + path, 403); } else if (Files.notExists(folder)) { try { Files.createDirectories(folder); } catch (IOException e) { log.error("Error creating repository folder " + folder, e); throw new WebApplicationException("Invalid upload folder: " + path, 403); } } List<String> result = new ArrayList<>(); FileItemFactory factory = newDiskFileItemFactory(servletContext); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); for (FileItem item : items) { if (!item.isFormField()) { // Argh - IE includes the path in the item.getName()! String fileName = Paths.get(item.getName()).getFileName().toString(); File destFile = getUniqueFile(folder, fileName).toFile(); log.info("File " + fileName + " is uploaded to " + destFile); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(destFile))) { InputStream in = new BufferedInputStream(item.getInputStream()); byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len != -1) { out.write(buffer, 0, len); len = in.read(buffer); } out.flush(); } // Return the repo-relative path as a result result.add(Paths.get(path, fileName).toString()); } } return result; }
From source file:com.duroty.application.mail.actions.SendAction.java
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages errors = new ActionMessages(); try {//from w w w . ja v a2 s . c o m boolean isMultipart = FileUpload.isMultipartContent(request); Mail mailInstance = getMailInstance(request); if (isMultipart) { Map fields = new HashMap(); Vector attachments = new Vector(); //Parse the request List items = diskFileUpload.parseRequest(request); //Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { if (item.getFieldName().equals("forwardAttachments")) { String[] aux = item.getString().split(":"); MailPartObj part = mailInstance.getAttachment(aux[0], aux[1]); attachments.addElement(part); } else { fields.put(item.getFieldName(), item.getString()); } } else { if (!StringUtils.isBlank(item.getName())) { ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); IOUtils.copy(item.getInputStream(), baos); MailPartObj part = new MailPartObj(); part.setAttachent(baos.toByteArray()); part.setContentType(item.getContentType()); part.setName(item.getName()); part.setSize(item.getSize()); attachments.addElement(part); } catch (Exception ex) { } finally { IOUtils.closeQuietly(baos); } } } } String body = ""; if (fields.get("taBody") != null) { body = (String) fields.get("taBody"); } else if (fields.get("taReplyBody") != null) { body = (String) fields.get("taReplyBody"); } Preferences preferencesInstance = getPreferencesInstance(request); Send sendInstance = getSendInstance(request); String mid = (String) fields.get("mid"); if (StringUtils.isBlank(mid)) { request.setAttribute("action", "compose"); } else { request.setAttribute("action", "reply"); } Boolean isHtml = null; if (StringUtils.isBlank((String) fields.get("isHtml"))) { isHtml = new Boolean(preferencesInstance.getPreferences().isHtmlMessage()); } else { isHtml = Boolean.valueOf((String) fields.get("isHtml")); } sendInstance.send(mid, Integer.parseInt((String) fields.get("identity")), (String) fields.get("to"), (String) fields.get("cc"), (String) fields.get("bcc"), (String) fields.get("subject"), body, attachments, isHtml.booleanValue(), Charset.defaultCharset().displayName(), (String) fields.get("priority")); } else { errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "mail.send", "The form is null")); request.setAttribute("exception", "The form is null"); request.setAttribute("newLocation", null); doTrace(request, DLog.ERROR, getClass(), "The form is null"); } } catch (Exception ex) { String errorMessage = ExceptionUtilities.parseMessage(ex); if (errorMessage == null) { errorMessage = "NullPointerException"; } errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage)); request.setAttribute("exception", errorMessage); doTrace(request, DLog.ERROR, getClass(), errorMessage); } finally { } if (errors.isEmpty()) { doTrace(request, DLog.INFO, getClass(), "OK"); return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD); } else { saveErrors(request, errors); return mapping.findForward(Constants.ACTION_FAIL_FORWARD); } }