List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding
public void setCharacterEncoding(String env) throws UnsupportedEncodingException;
From source file:com.swiftcorp.portal.question.web.QuestionDispatchAction.java
public ActionForward modifyQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws SystemException, BusinessRuleViolationException, Exception { log.info("modifyQuestion() : Enter"); request.setCharacterEncoding("UTF-16"); String mcqOptionNumber = request.getParameter("mcqOptionNumber"); int mcqNo = 0; if (mcqOptionNumber != null && !mcqOptionNumber.equals("null") && mcqOptionNumber.length() > 0) { mcqNo = Integer.parseInt(mcqOptionNumber); }/*from www. j a v a2s . c o m*/ DynaValidatorActionForm questionForm = (DynaValidatorActionForm) form; QuestionDTO questionsessDTO = (QuestionDTO) request.getSession() .getAttribute(SESSION_KEYS.QUESTION_TO_MODIFY); QuestionDTO questionDTO = (QuestionDTO) questionForm.get("question"); questionDTO = (QuestionDTO) this.questionService.get(questionDTO.getComponentId()); long categoryId = (Long) questionForm.get("category"); // set question id String questionId = request.getParameter("question.questionId"); String questionName = (String) request.getParameter("question.questionName"); questionDTO.setQuestionName(questionName); questionDTO.setQuestionId("" + questionId); // now get the role dto from the database CategoryTypeDTO categoryTypeDTO = (CategoryTypeDTO) questionService.getCategory(categoryId); if (categoryTypeDTO == null) { throw new SystemException("Category is found null"); } questionDTO.setCategoryType(categoryTypeDTO); long answerTypeId = (Long) questionForm.get("answerType"); AnswerTypeDTO answerTypeDTO = (AnswerTypeDTO) questionService.getAnswerType(answerTypeId); if (answerTypeDTO == null) { throw new SystemException("Answer is found null"); } questionDTO.setAnswerType(answerTypeDTO); List<ValidationDTO> validationDTOList = questionDTO.getValidationDTOList(); if (validationDTOList != null && validationDTOList.size() > 0) { ValidationDTO validationDTO = validationDTOList.get(0); // mcqoptions.remove ( mcqOptionDTO ); questionService.deleteValidation(validationDTO); } validationDTOList = this.populateValidationDTOFromReq(questionDTO, request, answerTypeDTO); questionDTO.setValidationDTOList(validationDTOList); /* * String searchSqlQuery * ="select componentId,name,questionId,questionOrder from mcqOption"; * searchSqlQuery += " where questionId= "+questionDTO.getComponentId * ()+" order by questionOrder asc"; System.out.println * ("search query::"+searchSqlQuery ); SearchOperationResult * searchOperationResult = questionService.search ( searchSqlQuery ); */ // encode the question name questionName = questionDTO.getQuestionName(); String utfQuestionName = new String(questionName.getBytes("UTF-16"), "UTF-16"); System.out.println("Converted: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + questionName + " to:" + utfQuestionName); questionDTO.setQuestionName(utfQuestionName); List<MCQOptionDTO> mcqoptions = questionDTO.getMcqOptionList(); for (MCQOptionDTO mcqOptionDTO : mcqoptions) { if (mcqOptionDTO != null) { // mcqoptions.remove ( mcqOptionDTO ); questionService.deleteMcqOption(mcqOptionDTO); } } mcqoptions.removeAll(mcqoptions); MCQOptionDTO mcqOptionDTO = null; for (int i = 0; i < mcqNo; i++) { // mcqoptions.add(questionService.getMCQDTO(Long.parseLong(request.getParameter("mcq"+i)))); mcqOptionDTO = new MCQOptionDTO(); mcqOptionDTO.setName(request.getParameter("mcq" + i)); mcqOptionDTO.setValue(request.getParameter("value" + i)); // mcqOptionDTO.setValue ( i ); mcqOptionDTO.setQuestionDTO(questionDTO); mcqoptions.add(mcqOptionDTO); } // mcqoptions = questionDTO.getMcqOptionList (); // System.out.println("mcq list size::::::"+questionDTO.getMcqOptionList().size()); // mcqoptions.remove ( 0 ); // questionDTO.setMcqOptionList ( mcqoptions ); // System.out.println("mcq list size::::::"+questionsessDTO.getMcqOptionList().size()); if (answerTypeId == ApplicationConstants.MULTIPLE_CHOICE_QUESTION_TYPE && mcqoptions != null && mcqoptions.size() > 0) { questionDTO.setMcqOptionList(mcqoptions); } String[][] messageArgValues = { { questionDTO.getQuestionName() } }; questionService.modify(questionDTO); WebUtils.setSuccessMessages(request, MessageKeys.MODIFY_SUCCESS_MESSAGE_KEYS, messageArgValues); log.info("modifyQuestion() : Exit"); return promptQuestionSearchSystemLevel(mapping, form, request, response); }
From source file:org.ajax4jsf.webapp.BaseFilter.java
/** * @param httpServletRequest// w w w.j a va 2 s. c o m * @throws UnsupportedEncodingException */ protected void setupRequestEncoding(HttpServletRequest httpServletRequest) throws UnsupportedEncodingException { String contentType = httpServletRequest.getHeader("Content-Type"); String characterEncoding = lookupCharacterEncoding(contentType); if (characterEncoding == null) { HttpSession session = httpServletRequest.getSession(false); if (session != null) { characterEncoding = (String) session.getAttribute(ViewHandler.CHARACTER_ENCODING_KEY); } if (characterEncoding != null) { httpServletRequest.setCharacterEncoding(characterEncoding); } } }
From source file:Control.FrontControl.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w. j a v a 2s. co m * * @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 { request.setCharacterEncoding("UTF-8"); //Characterencoding for special characters //This part of the code, checks if there might be files for upload, and seperates them, if that is the case Collection<Part> parts = null; if (ServletFileUpload.isMultipartContent(request)) { parts = request.getParts(); //Extracts the part of the form that has files and parameters } HttpSession sessionObj = request.getSession(); //Get the session DomainFacade df = (DomainFacade) sessionObj.getAttribute("Controller"); //Get the DomainFacede //If it is a new session, create a new DomainFacade Object and put it in the session. sessionObj.setAttribute("testing", testing); if (df == null) { df = DomainFacade.getInstance(); sessionObj.setAttribute("Controller", df); } //Set base url String url = "/index.jsp"; String action = request.getParameter("action"); if (action == null) { action = ""; } String page = request.getParameter("page"); if (testing) { System.out.println("Redirect parameter (page) set to:"); } if (testing) { System.out.println(page); } try { if (page == null) { page = ""; } //For creating a new report if (page.equalsIgnoreCase("newreport")) { url = "/reportJSPs/choosebuilding.jsp"; sessionObj.setAttribute("customerSelcted", false); cuh.chooseCustomer(sessionObj, df); } //For choosing the customer //TODO split redirect and action if (page.equalsIgnoreCase("report_cus_choosen")) { url = "/reportJSPs/choosebuilding.jsp"; bh.loadCustomersBuildings(request, sessionObj, df); } //When building has been chosen, it sets up the report object if (page.equalsIgnoreCase("report_start")) { url = "/reportJSPs/report_start.jsp"; rh.createReport(request, sessionObj, df); } //For choosing room when setting up report, after exterior has been added if (page.equalsIgnoreCase("ChooseRoom")) { url = "/reportJSPs/chooseroom.jsp"; rh.saveReportExterior(request, sessionObj, parts, this); } //For inspecting the chosen room. if (page.equalsIgnoreCase("inspectRoom")) { url = "/reportJSPs/reportaddaroom.jsp"; rh.setUpForRoomInspection(request, sessionObj, df, parts); } //For submitting what is written about the room if (page.equalsIgnoreCase("submittedRoom")) { url = "/reportJSPs/chooseroom.jsp"; rh.createReportRoomElements(request, sessionObj, parts, this); } //Saving finished report and redirection to report view. if (page.equalsIgnoreCase("saveFinishedReport")) { url = "/viewreport.jsp"; rh.finishReportObject(request, sessionObj); int reportId = rh.saveFinishedReport(sessionObj, df); request.getSession().setAttribute("report", df.getReport(reportId)); } if (page.equalsIgnoreCase("toFinishReport")) { url = "/reportJSPs/finishreport.jsp"; } if (page.equalsIgnoreCase("backToChooseRoom")) { url = "/reportJSPs/chooseroom.jsp"; } //For inspecting a room you just added to the building if (page.equalsIgnoreCase("inspectRoomjustCreated")) { url = "/reportJSPs/reportaddaroom.jsp"; bh.createNewRoom(request, sessionObj, df); rh.setUpForRoomInspection(request, sessionObj, df, parts); } //List all reports for all customers if (page.equalsIgnoreCase("listreports")) { sessionObj.setAttribute("reports", df.getListOfReports(1)); response.sendRedirect("viewreports.jsp"); return; } if (page.equalsIgnoreCase("addbuilding")) { url = "/addbuilding.jsp"; } if (page.equalsIgnoreCase("addcustomer")) { url = "/addcustomer.jsp"; } //Viewing the list of all the if (page.equalsIgnoreCase("viewmybuildings")) { bh.findListOfBuilding(request, df, sessionObj); User tempUser = (User) request.getSession().getAttribute("user"); List<Building> buildings = df.getListOfBuildings(tempUser.getCustomerid()); url = "/viewcustomer.jsp"; sessionObj.setAttribute("buildings", buildings); } //Edit a building if (page.equalsIgnoreCase("editBuilding")) { bh.findBuildingToBeEdit(request, sessionObj, df); response.sendRedirect("editBuilding.jsp"); return; } if (page.equalsIgnoreCase("viewreport")) { int reportId = Integer.parseInt(request.getParameter("reportid")); Report report = df.getReport(reportId); sessionObj.setAttribute("report", report); response.sendRedirect("viewreport.jsp"); return; } if (page.equalsIgnoreCase("viewcustomers")) { List<Customer> customers = df.loadAllCustomers(); sessionObj.setAttribute("customers", customers); response.sendRedirect("viewcustomers.jsp"); return; } if (page.equalsIgnoreCase("viewcustomer")) { int custId = Integer.parseInt(request.getParameter("customerid")); sessionObj.setAttribute("customer_id", custId); List<Building> buildings = df.getListOfBuildings(custId); List<Customer> customers = df.loadAllCustomers(); for (Customer customer : customers) { if (customer.getCustomerId() == custId) { sessionObj.setAttribute("customer", customer); } } sessionObj.setAttribute("buildings", buildings); response.sendRedirect("viewcustomer.jsp"); return; } //This gets a Dashboard for a building if (page.equalsIgnoreCase("viewbuildingadmin")) { System.out.println("Did it go here?"); int buildId = Integer.parseInt(request.getParameter("buildingid")); Building b = df.getBuilding(buildId); sessionObj.setAttribute("building", b); response.sendRedirect("viewbuildingadmin.jsp"); return; } //TODO seperate redirect and action if (page.equalsIgnoreCase("newbuilding")) { Building b = bh.createBuilding(request, df, sessionObj, parts, this); response.sendRedirect("viewnewbuilding.jsp"); return; } //TODO: seperate action and redirect if (page.equalsIgnoreCase("vieweditedbuilding")) { Building b = bh.updateBuilding(request, df, sessionObj, parts, this); response.sendRedirect("viewbuildingadmin.jsp"); return; } //TODO: seperate action and redirect if (page.equalsIgnoreCase("submitcustomer")) { cuh.createNewCustomer(request, df, sessionObj, this); response.sendRedirect("customersubmitted.jsp"); return; } if (page.equalsIgnoreCase("addfloorsubmit")) { bh.addFloors(request, df, sessionObj, this); response.sendRedirect("addfloor.jsp"); return; } if (page.equalsIgnoreCase("selBdg")) { bh.selectBuilding(request, df, sessionObj, this); response.sendRedirect("addfloor.jsp"); return; } if (page.equalsIgnoreCase("addfloor")) { sessionObj.setAttribute("customerSelcted", false); cuh.chooseCustomer(sessionObj, df); response.sendRedirect("addfloor.jsp"); return; } if (page.equalsIgnoreCase("selCust")) { bh.loadCustomersBuildings(request, sessionObj, df); response.sendRedirect("addfloor.jsp"); return; } if (page.equalsIgnoreCase("loadFloors")) { bh.loadFloors(request, sessionObj, df, this); response.sendRedirect("addfloor.jsp"); return; } if (page.equalsIgnoreCase("selFlr")) { bh.selectFloor(request, sessionObj, df, this); response.sendRedirect("addroom.jsp"); return; } if (page.equalsIgnoreCase("loadRooms")) { bh.loadRooms(request, sessionObj, df, this); response.sendRedirect("addroom.jsp"); return; } if (page.equalsIgnoreCase("addroomsubmit")) { bh.addRoom(request, sessionObj, df, this); response.sendRedirect("addroom.jsp"); return; } //loading order request page if (page.equalsIgnoreCase("orderRequest")) { bh.loadBuildingsAfterLogIn(sessionObj, df, this); response.sendRedirect("orderRequest.jsp"); return; } //selecting a building for order request if (page.equalsIgnoreCase("selBdgReq")) { bh.selectBuilding(request, df, sessionObj, this); response.sendRedirect("orderRequest.jsp"); return; } //create an order request if (page.equalsIgnoreCase("orderRequestSubmit")) { oh.saveOrder(request, sessionObj, df, this); response.sendRedirect("ordersuccess.jsp"); return; } //displays the order history and order progress if (page.equalsIgnoreCase("orderhistory")) { oh.loadCustomerOrders(sessionObj, df, this); response.sendRedirect("orderhistory.jsp"); return; } //displays the order list and order progress if (page.equalsIgnoreCase("orderslist")) { oh.loadAllOrders(sessionObj, df); response.sendRedirect("orderslist.jsp"); return; } //displays the order details if (page.equalsIgnoreCase("vieworder")) { int orderNumber = Integer.parseInt(request.getParameter("ordernumber")); sessionObj.setAttribute("orderNumber", orderNumber); sessionObj.setAttribute("selectedOrder", df.getOrder(orderNumber)); response.sendRedirect("vieworder.jsp"); return; } //updates the order progress if (page.equalsIgnoreCase("updateStat")) { int newStat = Integer.parseInt(request.getParameter("orderstatus")); Order o = (Order) sessionObj.getAttribute("selectedOrder"); df.updateStatus(o.getOrderNumber(), newStat); oh.loadAllOrders(sessionObj, df); response.sendRedirect("orderslist.jsp"); return; } if (page.equalsIgnoreCase("continue")) { url = "/addroom.jsp"; } if (page.equalsIgnoreCase("login")) { url = "/login.jsp"; } if (page.equalsIgnoreCase("loguserin")) { if (request.getParameter("empOrCus").equals("emp")) { cuh.emplogin(df, request, response); } else { cuh.login(df, request, response); } url = "/login.jsp"; } if (page.equalsIgnoreCase("logout")) { request.setAttribute("user", null); request.setAttribute("loggedin", false); request.getSession().invalidate(); url = "/index.jsp"; } if (page.equalsIgnoreCase("printReport")) { rh.printReport(sessionObj, df, response, this); return; } if (request.getServletPath().equalsIgnoreCase("/viewreports")) { url = "/viewreports.jsp"; } if (request.getServletPath().equalsIgnoreCase("/getreport")) { url = "/viewreport.jsp"; } System.out.println(request.getServletPath()); System.out.println(request.getMethod()); //get the building and send it to the sessionobj System.out.println("test of action: " + action); if (action.equalsIgnoreCase("viewbuildingadmin")) { System.out.println("test!"); int buildId = Integer.parseInt(request.getParameter("buildingid")); Building b = df.getBuilding(buildId); request.getSession().setAttribute("building", b); request.setAttribute("showBuilding", true); url = "/viewbuildingadmin.jsp"; } //retrieve a room from the buildingobject and put it in response. if (action.equalsIgnoreCase("viewroom")) { Building b = (Building) request.getSession().getAttribute("building"); int roomNumber; String viewReportRoomString = request.getParameter("viewroom"); if (viewReportRoomString != null && b != null) { roomNumber = Integer.parseInt(viewReportRoomString); BuildingRoom r = b.returnARoom(roomNumber); request.getSession().setAttribute("room", r); request.getSession().setAttribute("building", b); request.setAttribute("showRoom", true); url = "/viewbuildingadmin.jsp"; } } if (action.equalsIgnoreCase("addfloor")) { request.setAttribute("addFloor", true); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addroom")) { int floorId = Integer.parseInt(request.getParameter("floor")); request.setAttribute("addRoom", true); request.setAttribute("floorId", floorId); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("listreports")) { request.getSession().setAttribute("reports", df.getSimpleListOfReports()); } if (action.equalsIgnoreCase("addfloorsubmit")) { bh.addFloors(request, df); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addroomsubmit")) { int floorId = Integer.parseInt(request.getParameter("floorID")); bh.addRoom(request, df, floorId); request.setAttribute("showBuilding", true); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("editbuilding")) { request.setAttribute("editBuilding", true); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("showBuilding")) { request.setAttribute("showBuilding", true); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("showreport")) { int reportId = Integer.parseInt(request.getParameter("reportid")); Report report = df.getReport(reportId); Building b = df.getBuilding(report.getBuildingId()); report.setBuildingName(b.getBuildingName()); // request.getSession().setAttribute("report", report); } if (action.equalsIgnoreCase("reportroom")) { int reportRoomId = Integer.parseInt(request.getParameter("viewroom")); Report report = (Report) request.getSession().getAttribute("report"); ReportRoom rr = report.getReportRoomFromReportFloor(reportRoomId); // request.setAttribute("reportroom", rr); request.setAttribute("showroom", true); url = "/viewreport.jsp"; } //Trying to see if I can work this out if (action.equalsIgnoreCase("roomfiles")) { //int buildId = Integer.parseInt(request.getParameter("buildingid")); request.setAttribute("roomfiles", true); //request.setAttribute("reportroom", report.getReportRoomFromReportFloor(roomId) ); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addfloorplans")) { Building b = (Building) request.getSession().getAttribute("building"); ArrayList<BuildingFloor> bfList = df.listOfFloors(b.getBdgId()); ArrayList<Floorplan> plans = df.getFloorplans(bfList); request.getSession().setAttribute("floorplans", plans); request.getSession().setAttribute("floorsList", bfList); request.setAttribute("addfloorplans", true); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addfilessubmit")) { request = nfu.addFiles(request, parts, df, this); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addfloorplanssubmit")) { request = nfu.addFloorplans(request, parts, df, this); url = "/viewbuildingadmin.jsp"; } if (action.equalsIgnoreCase("addBuilding")) { Building b = new Building(); b.setBuildingName("tempname"); request.getSession().setAttribute("building", b); } if (action.equalsIgnoreCase("viewbuildingadmin")) { int buildId = Integer.parseInt(request.getParameter("buildingid")); Building b = df.getBuilding(buildId); request.getSession().setAttribute("building", b); } if (action.equalsIgnoreCase("viewbuildingreports")) { request.setAttribute("viewbuildingreports", true); url = "/viewbuildingadmin.jsp"; } } catch (PolygonException ex) { Logger.getLogger(FrontControl.class.getName()).log(Level.SEVERE, null, ex); request.setAttribute("errormessage", ex.getMessage()); url = "/errorpage.jsp"; } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url); dispatcher.forward(request, response); }
From source file:net.duckling.ddl.web.controller.LynxEmailResourceController.java
/** * ?email/* w w w . j a va 2s . c o m*/ * @param request * @param response * @throws UnsupportedEncodingException */ @RequestMapping public void dealEmailFile(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException { request.setCharacterEncoding("utf-8"); if (!ClientValidator.validate(request)) { writeSenderError(response, NO_AUTH, "", ""); return; } String fileName = ""; if (StringUtils.isNotEmpty(request.getParameter("fileName"))) { fileName = URLDecoder.decode(request.getParameter("fileName"), "UTF-8"); } String userEmail = request.getParameter("email"); String mid = request.getParameter("mid"); if (!EmailUtil.isValidEmail(userEmail)) { writeSenderError(response, EMAIL_ERROR, "", fileName); return; } try { Integer.parseInt(request.getParameter("clbId")); Long.parseLong(request.getParameter("fileSize")); } catch (RuntimeException e) { writeSenderError(response, CLB_ID_ERROR, "", fileName); return; } int tid = getSaveAttaTid(request, userEmail); try { FileVersion fileVersion = saveFile(tid, request); addFileTag(tid, fileVersion, userEmail); String attachmentURL = VWBContainerImpl.findContainer().getBaseURL() + urlGenerator.getURL(tid, UrlPatterns.T_VIEW_R, fileVersion.getRid() + "", null); emailAttachmentService.createEmailAttach(createEmailAttachment(userEmail, mid, fileVersion)); eventDispatcher.sendFileUploadEvent(fileVersion.getTitle(), fileVersion.getRid(), userEmail, tid); if (SupportedFileFormatForOnLineViewer.isSupported(MimeType.getSuffix(fileVersion.getTitle()))) { resourceOperateService.sendPdfTransformEvent(fileVersion.getClbId(), fileVersion.getClbVersion() + ""); } LOG.info(request.getRemoteHost() + "ddl" + fileVersion.getTid() + "" + userEmail + "[" + fileVersion.getTitle() + "]?" + fileVersion.getSize()); writeSenderError(response, NORMAL, attachmentURL, fileVersion.getTitle()); } catch (RuntimeException e) { LOG.error("?email", e); writeSenderError(response, ERROR, "", fileName); } }
From source file:org.jlibrary.web.servlet.JLibraryForwardServlet.java
private void processRequest(HttpServletRequest req, HttpServletResponse resp) { try {//from w w w .ja v a 2 s .co m req.setCharacterEncoding("ISO-8859-1"); resp.setCharacterEncoding("ISO-8859-1"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } if (ServletFileUpload.isMultipartContent(req)) { upload(req, resp); } if (logger.isDebugEnabled()) { logger.debug("Received content upload request"); } String method; try { method = getField(req, resp, "method"); } catch (FieldNotFoundException e) { return; } if (method.equals("update")) { update(req, resp); } else if (method.equals("create")) { create(req, resp); } else if (method.equals("delete")) { delete(req, resp); } else if (method.equals("comment")) { addComment(req, resp); } else if (method.equals("login")) { login(req, resp); } else if (method.equals("signin")) { signin(req, resp); } else if (method.equals("register")) { register(req, resp); } else if (method.equals("logout")) { logout(req, resp); } else if (method.equals("updateform")) { updateform(req, resp); } else if (method.equals("createform")) { createform(req, resp); } else if (method.equals("upload")) { upload(req, resp); } else if (method.equals("documentcategories")) { documentCategoriesForm(req, resp); } else if (method.equals("updatedocumentcategories")) { updateDocumentCategories(req, resp); } else if (method.equals("documentdocuments")) { documentDocumentsForm(req, resp); } else if (method.equals("updatedocumentrelations")) { updateDocumentRelations(req, resp); } else { try { if (logger.isDebugEnabled()) { logger.error("The operation " + method + " is not supported."); } String repositoryName = getField(req, resp, "repository"); String refererURL = getRefererURL(req, repositoryName); RequestDispatcher rd = getServletContext().getRequestDispatcher(refererURL); req.setAttribute("error", "The operation specified is not supported."); rd.forward(req, resp); } catch (Exception fe) { logger.error(fe.getMessage(), fe); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } return; }
From source file:com.devpia.service.DEXTUploadJController.java
/** * ? ? ? behind.down ? ? ?? /* w w w . ja va 2 s . co m*/ * ??? ??(?) . * @param req HttpServletRequest ? * @param res HttpServletResponse ? * @throws Exception */ @RequestMapping(value = "/behind.down", method = RequestMethod.GET) public void download(HttpServletRequest req, HttpServletResponse res, @RequestParam(value = "atchmnflId") String atchmnflId, @RequestParam(value = "changeInfoId") String changeInfoId) throws Exception { req.setCharacterEncoding("utf-8"); // UTF-8 ? ?? QueryString ? . //String filename = new String(req.getParameter("DownloadInfo").getBytes("8859_1"), "utf-8"); FileDownload dextj = new FileDownload(req, res); // ?? ? . // ? . // File repository = new File(req.getSession().getServletContext().getRealPath("/Datas/")); File repository = new File(getUploadDirectory()); TnAtchmnflVO searchVo = new TnAtchmnflVO(); searchVo.setAtchmnflId(new BigDecimal(atchmnflId)); searchVo.setChangeInfoId(new BigDecimal(changeInfoId)); TnAtchmnflVO fileVO = tnAtchmnflService.selectTnAtchmnfl(searchVo); String filename = fileVO.getFlpthNm(); try { // ? ? ? ?? . if (!repository.exists() || !repository.canRead()) { throw new Exception( "? ? ? ."); } File target = new File(repository, filename); if (target.exists()) { dextj.Download(target.getAbsolutePath(), true, false); } else { res.sendError(404, filename.concat(" not found")); } } catch (DEXTUploadException ex) { throw new IOException(" ? .", ex); } catch (Exception ex) { throw new IOException(" ? .", ex); } finally { } }
From source file:org.castafiore.web.servlet.CastafioreServlet.java
@SuppressWarnings("unchecked") @Override//from ww w. java 2 s .c o m public void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean isMultipart = ServletFileUpload.isMultipartContent((HttpServletRequest) request); //loads application based on parameters ComponentUtil.loadApplication((HttpServletRequest) request, (HttpServletResponse) response); if (isMultipart) { //handle upload handleMultipartRequest((HttpServletRequest) request, response); } else if ("true".equals(request.getParameter("upload"))) { doGeter(request, response); } else { //if(logger.isDebugEnabled()) //logger.debug("handling normal action request"); request.setCharacterEncoding("UTF-8"); Map<String, String> params = this.getParameterMap(request.getParameterMap()); String componentId = request.getParameter("casta_componentid"); String eventId = request.getParameter("casta_eventid"); String applicationId = request.getParameter("casta_applicationid"); Assert.notNull(applicationId, "cannot execute a castafiore request when the applicationid is null. Please verify that the parameter casta_applicationid has been set correctly in tag, jsp or whatever"); //gets the already loaded application Application applicationInstance = CastafioreApplicationContextHolder.getCurrentApplication(); String script = ""; if ((componentId == null && eventId == null && applicationInstance != null)) { //first access to the application. componentId and EventId should be null //if(logger.isDebugEnabled()) //logger.debug("re-rendering the application"); applicationInstance.setRendered(false); //if(logger.isDebugEnabled()) //logger.debug("re-generate jquery for application"); script = getEngine(request).getJQuery(applicationInstance, "root_" + applicationId, applicationInstance, new ListOrderedMap()); script = script + "hideloading();"; } else if ((componentId != null && eventId != null) && applicationInstance != null) { //if(logger.isDebugEnabled()) //logger.debug("executing server action: componentId:" + componentId + " applicationid:" + applicationId); try { long start = System.currentTimeMillis(); script = getEngine(request).executeServerAction(componentId, applicationInstance, "root_" + applicationId, params); //System.out.println("login executed in :" + start + " ms"); script = script + "hideloading();"; //script = script + "jQuery('.loadmask').css('display','none');jQuery('.loadmask-msg').css('display','none');"; } catch (ComponentNotFoundException cnfe) { //script = "alert('Your session has expired. Browser will refresh');window.location.reload( false );"; script = "window.location.reload( false );"; } } else if ((componentId != null && eventId != null) && applicationInstance == null) { // if(logger.isDebugEnabled()) //logger.debug("session must have been timed out"); script = "alert('Your session has expired. Browser will refresh');window.location.reload( false );"; } Set<String> requiredScript = applicationInstance.getBufferedResources(); if (requiredScript != null && requiredScript.size() > 0) { StringBuilder reqScript = new StringBuilder(); reqScript.append(Constant.NO_CONFLICT + ".plugin('" + applicationInstance.getId() + "',{") .append("files:["); int scount = 0; for (String s : requiredScript) { reqScript.append("'").append(s).append("'"); scount++; if (scount < requiredScript.size()) { reqScript.append(","); } } reqScript.append("],").append("selectors:['" + Constant.ID_PREF + "root_" + applicationId + "'],"); reqScript.append("callback:function(){").append(script).append("}").append("});"); reqScript.append(Constant.NO_CONFLICT + ".plugin('" + applicationInstance.getId() + "').get();"); script = reqScript.toString(); } //if(logger.isDebugEnabled()) //logger.debug(script); //System.out.println(script); applicationInstance.flush(12031980); //script = Constant.NO_CONFLICT +"(document).ready(function(){" + script + "});"; script = "<script>" + Constant.NO_CONFLICT + "(document).ready(function(){" + script + "});</script>"; //if(request.getServletPath().contains("ado.cst")){ //url mode //request.getSession().setAttribute("script", script); //response.sendRedirect("adap.jsp?casta_applicationid=" + applicationId); //}else{ //ajax mode //String encoding = ((HttpServletRequest)request).getHeader("Accept-Encoding"); //boolean supportsGzip =false; //if (encoding != null) { //if (encoding.toLowerCase().indexOf("gzip") > -1) //supportsGzip = true; //} //if(supportsGzip){ //((HttpServletResponse)response).setHeader("Content-Encoding", "gzip"); //GZIPOutputStream out = new GZIPOutputStream(response.getOutputStream()); //out.write(script.getBytes()); //out.finish(); //}else{ response.getOutputStream().write(script.getBytes()); //} //} } }
From source file:controlador.CPersona.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/* ww w.ja v a2 s.co m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); //request.setCharacterEncoding("charset=utf-8"); response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); request.setCharacterEncoding("UTF-8"); Persona persona = null; FormacionAcademica academica = null; ExperienciaLaboral experienciaLaboral = null; int PERSONA_personaId; PrintWriter out = response.getWriter(); int opc = Integer.parseInt(request.getParameter("OPC")); switch (opc) { case Constans.LISTARPERSONA: ArrayList<Persona> personas = interPersona .listarPersona(Integer.parseInt(request.getParameter("IDPERSONA"))); String jsonPersona = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(personas); out.println(jsonPersona); break; case Constans.ACTUALIZARPERSONA://This is for save update int id = Integer.parseInt(request.getParameter("ID")); String nombres = request.getParameter("NOMBRES"); String apPaterno = request.getParameter("PATERNO"); String apMaterno = request.getParameter("MATERNO"); String direccion = request.getParameter("DIRECCION"); String celular = request.getParameter("CELULAR"); String correo = request.getParameter("CORREO"); String dni = request.getParameter("DNI"); String fecha = request.getParameter("FECHAN"); String civil = request.getParameter("CIVIL"); String nacionalidad = request.getParameter("NACIONALIDAD"); int idregimen = Integer.parseInt(request.getParameter("IDREGIMEN")); String lugarNacimiento = request.getParameter("LUGAR"); String url = request.getParameter("URL"); persona = new Persona(id, nombres, apPaterno, apMaterno, direccion, celular, correo, dni, url, civil, nacionalidad, fecha, "", idregimen, lugarNacimiento, ""); int actualizo = interPersona.actualizarPersona(persona); out.println(actualizo); break; case Constans.CREARPERSONA: String dniP = request.getParameter("DNI"); int inserto = interPersona.crearPorDni(dniP); out.println(inserto); break; case Constans.CREARFORMACIONACADEMICA: String especialidad = request.getParameter("ESPECIALIDAD"); String fecha_concluye = request.getParameter("FECHA"); int nivelFormacion = Integer.parseInt(request.getParameter("NIVEL")); int idPersona = Integer.parseInt(request.getParameter("IDPERSONA")); int estadoConcluyo = Integer.parseInt(request.getParameter("ESTADO")); String nombreIns = request.getParameter("NOMBRE"); academica = new FormacionAcademica(0, especialidad, fecha_concluye, 1, estadoConcluyo, nivelFormacion, idPersona, "", nombreIns); int es = interPersona.agregarFormacionAcademica(academica); out.println(es); break; case Constans.LISTARFORMACIONACADEMICA: int ids = Integer.parseInt(request.getParameter("ID")); ArrayList<FormacionAcademica> academ = interPersona.listarFormacionAcademica(ids); String jsonStringl = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(academ); out.println(jsonStringl); break; case Constans.ELIMINARFORMACIONACADEMICA: int idFormacion = Integer.parseInt(request.getParameter("IDFORMACION")); int estadoEl = interPersona.eliminarFormacion(idFormacion); out.println(estadoEl); break; case Constans.LISTARCOMBONIVELFORMACION: ArrayList<NivelFormacion> nivelFormacions = interPersona.listarNivelesFormacion(); String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(nivelFormacions); out.println(json); break; case Constans.AGREGAREXPLABORAL: String dependencia = request.getParameter("DEPENDENCIA"); String cargo = request.getParameter("CARGO"); int tipo = Integer.parseInt(request.getParameter("TIPO")); String annoInicio = request.getParameter("AINICIO"); String annoFin = request.getParameter("AFIN"); String lugar = request.getParameter("LUGAR"); PERSONA_personaId = Integer.parseInt(request.getParameter("IDPERSONA")); experienciaLaboral = new ExperienciaLaboral(0, dependencia, cargo, annoInicio, annoFin, lugar, tipo, "", PERSONA_personaId, ""); int agregar = interPersona.agregarExperienciaLaboral(experienciaLaboral); out.println(agregar); break; case Constans.LISTARCOMBOREXPLABORAL: String tipoDes = request.getParameter("TIPODESCRIPCION"); ArrayList<Tipos> arrayListipos = interPersona.listComboTipos(tipoDes); String jsonTipos = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(arrayListipos); out.println(jsonTipos); break; case Constans.LISTAREXPROFESIONAL: int idPers = Integer.parseInt(request.getParameter("IDPERSONA")); ArrayList<ExperienciaLaboral> experienciaLaborals = interPersona.lisExperienciaLaboral(idPers); String jsonExpP = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(experienciaLaborals); out.println(jsonExpP); break; case Constans.ELIMINAREXPROFESIONAL: int idExpP = Integer.parseInt(request.getParameter("IDEXPROFE")); int estDelExpP = interPersona.eliminarExpLaboral(idExpP); out.println(estDelExpP); break; case Constans.LISTARCOMBOCATEGORIA: String tipoCat = request.getParameter("TIPODESCRIPCION"); ArrayList<Categoria> arrayListCat = interPersona.listarComboCategoria(tipoCat); String jsonCat = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(arrayListCat); out.println(jsonCat); break; case Constans.AGREGARCATEGORIA: String institucion = request.getParameter("INSTITUCION"); String categoria = request.getParameter("CATEDRA"); int catDocente = Integer.parseInt(request.getParameter("CATDOCENTE")); String fechaIni = request.getParameter("DINICIO"); String fechaFin = request.getParameter("DFIN"); int idPer = Integer.parseInt(request.getParameter("PERSONA")); CategoriaDocente categoriaDocente = new CategoriaDocente(0, institucion, categoria, categoria, catDocente, fechaIni, fechaFin, "", idPer); int insCat = interPersona.agregarCategoria(categoriaDocente); out.println(insCat); break; case Constans.LISTARCATEGORIADOCENTE: int idPerCD = Integer.parseInt(request.getParameter("IDPERSONA")); ArrayList<CategoriaDocente> categoriaDocentes = interPersona.arrayListCategoriaDocente(idPerCD); String jsonCatDocente = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(categoriaDocentes); out.println(jsonCatDocente); break; case Constans.ELIMINARCATEGORIADOCENTE: int idCatDoc = Integer.parseInt(request.getParameter("IDCATDOC")); int estidCatDoc = interPersona.eliminarCatDocente(idCatDoc); out.println(estidCatDoc); break; case Constans.AGREGAREGIMENDOCENTE: String dedicacion = request.getParameter("DEDICACION"); String tCompleto = request.getParameter("TCOMPLETO"); String tParcial = request.getParameter("TPARCIAL"); String pasantia = request.getParameter("PASANTIA"); String practicante = request.getParameter("PRACTICANTE"); int idPerReg = Integer.parseInt(request.getParameter("IDPERSONA")); RegimenDocente regimenDocente = new RegimenDocente(0, dedicacion, tCompleto, tParcial, pasantia, practicante, 1, idPerReg); int insRD = interPersona.agregarRegimen(regimenDocente); out.println(insRD); break; case Constans.LISTAREGIMENDOCENTE: int idRD = Integer.parseInt(request.getParameter("IDPERSONA")); ArrayList<RegimenDocente> regimenDocentes = interPersona.listaRegimenDocente(idRD); String jsonRegDocente = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(regimenDocentes); out.println(jsonRegDocente); break; case Constans.ELIMINAREGIMENDOCENTE: int idRDE = Integer.parseInt(request.getParameter("IDREGDOC")); int delRD = interPersona.eliminarRegimenDocente(idRDE); out.println(delRD); break; case Constans.AGREGAREXPERIENCIA: String instiEdu = request.getParameter("INSTITUCION"); String catedraEdu = request.getParameter("CATEDRA"); int categoriaId = Integer.parseInt(request.getParameter("CATEGORIA")); int regimenId = Integer.parseInt(request.getParameter("REGIMENPEN")); String fechInicio = request.getParameter("FECHAINICIO"); String fechFin = request.getParameter("FECHAFIN"); String lugarEdu = request.getParameter("LUGAR"); int idPersEdu = Integer.parseInt(request.getParameter("IDPERSONA")); String resolucion = request.getParameter("RESOLUCION"); String funcion = request.getParameter("FUNCION"); int tipoExp = Integer.parseInt(request.getParameter("TIPO")); int idRegimenLaboral = Integer.parseInt(request.getParameter("REGIMENLABORAL")); int totalDiaz = 8; Experiencia experiencia = new Experiencia(0, catedraEdu, fechInicio, fechFin, "", lugarEdu, instiEdu, 1, resolucion, tipoExp, categoriaId, "", regimenId, "", idPersEdu, funcion, idRegimenLaboral, ""); int isExperiencia = interPersona.agregarExperiencia(experiencia); out.println(isExperiencia); break; case Constans.LISTAREXPERIENCIA: int idP = Integer.parseInt(request.getParameter("IDPERSONA")); int idTipoExp = Integer.parseInt(request.getParameter("TIPOEXPE")); ArrayList<Experiencia> experiencias = interPersona.listarExperiencia(idP, idTipoExp); String jsonExpDocUni = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(experiencias); out.println(jsonExpDocUni); break; case Constans.ELIMINAREXPERIENCIA: int idElExp = Integer.parseInt(request.getParameter("IDEXP")); int delIdExp = interPersona.eliminarExperiencia(idElExp); out.println(delIdExp); break; case Constans.AGREGARIDIOMA: String idiomaID = request.getParameter("IDIOMA"); int nivelID = Integer.parseInt(request.getParameter("NIVEL")); int dominioID = Integer.parseInt(request.getParameter("DOMINIO")); String institucionID = request.getParameter("INSTITUCION"); String anno = request.getParameter("ANNO"); int idPersonaID = Integer.parseInt(request.getParameter("IDPERSONA")); Idioma idioma = new Idioma(0, idiomaID, institucionID, anno, nivelID, "", dominioID, "", 1, idPersonaID); int insID = interPersona.agregarIdioma(idioma); out.println(insID); break; case Constans.LISTARIDIOMA: int idPID = Integer.parseInt(request.getParameter("IDPERSONA")); ArrayList<Idioma> idiomas = interPersona.listarIdioma(idPID); String jsonIdioma = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(idiomas); out.println(jsonIdioma); break; case Constans.ELIMINARIDIOMA: int idIdioma = Integer.parseInt(request.getParameter("ID")); int insIDa = interPersona.eliminarIdioma(idIdioma); out.println(insIDa); break; case Constans.AGREGARTECNOLOGIA: Tecnologia tecnologia = new Tecnologia(0, request.getParameter("TECNOLOGIA"), Integer.parseInt(request.getParameter("DOMINIO")), Integer.parseInt(request.getParameter("NIVEL")), 1, Integer.parseInt(request.getParameter("IDPERSONA")), "", ""); int insTec = interPersona.agregarTecnologia(tecnologia); out.println(insTec); break; case Constans.LISTARTECNOLOGIA: ArrayList<Tecnologia> tecnologias = interPersona .listarTecnologia(Integer.parseInt(request.getParameter("IDPERSONA"))); String jsonTec = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tecnologias); out.println(jsonTec); break; case Constans.ELIMINARTECNOLOGIA: int delTec = interPersona.eliminarTecnologia(Integer.parseInt(request.getParameter("ID"))); out.println(delTec); break; case Constans.AGREGARACTUALIZACION: Actualizacion actualizacion = new Actualizacion(0, request.getParameter("ANNO"), request.getParameter("PONENCIA"), request.getParameter("EVENTO"), request.getParameter("ENTIDAD"), request.getParameter("HORAS"), request.getParameter("LUGAR"), Integer.parseInt(request.getParameter("TIPO")), 1, Integer.parseInt(request.getParameter("IDPERSONA"))); int insActu = interPersona.agregarActualizacion(actualizacion); out.println(insActu); break; case Constans.LISTARACTUALIZACION: ArrayList<Actualizacion> arrayListActualizacion = interPersona.listarActualizacion( Integer.parseInt(request.getParameter("ID")), Integer.parseInt(request.getParameter("TIPO"))); String jsonActualizacion = mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(arrayListActualizacion); out.println(jsonActualizacion); break; case Constans.ELIMINARACTUALIZACION: int delActua = interPersona.eliminarActualizacion(Integer.parseInt(request.getParameter("ID"))); out.println(delActua); break; case Constans.AGREGARPASANTIA: Pasantia pasantia1 = new Pasantia(0, request.getParameter("ANNOINICIO"), request.getParameter("ANNOFIN"), request.getParameter("INSTITUCION"), request.getParameter("LABOR"), request.getParameter("LUGAR"), Integer.parseInt(request.getParameter("IDPERSONA"))); int insPasan = interPersona.agregarPasantia(pasantia1); out.println(insPasan); break; case Constans.LISTARPASANTIA: ArrayList<Pasantia> arrayListPasantia = interPersona .listarPasantia(Integer.parseInt(request.getParameter("ID"))); String jsonPasantia = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(arrayListPasantia); out.println(jsonPasantia); break; case Constans.ELIMINARPASANTIA: int delPasan = interPersona.eliminarPasantia(Integer.parseInt(request.getParameter("ID"))); out.println(delPasan); break; case Constans.LISTARINVESTIGACION: ArrayList<Investigacion> investigacions = interPersona.listarInvestigacion( Integer.parseInt(request.getParameter("ID")), Integer.parseInt(request.getParameter("TIPO"))); String jsonInventigacion = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(investigacions); out.println(jsonInventigacion); break; case Constans.AGREGARINVESTIGACION: Investigacion investigacion = new Investigacion(0, request.getParameter("ANNOPUB"), Integer.parseInt(request.getParameter("TIPOPUB")), request.getParameter("TITUPUB"), request.getParameter("MEDPU"), request.getParameter("EDIPUB"), request.getParameter("ISBN"), Integer.parseInt(request.getParameter("NROPAG")), request.getParameter("LUGPUB"), Integer.parseInt(request.getParameter("TIPOINVES")), request.getParameter("AUTOR"), request.getParameter("ANNO"), request.getParameter("ESPECIALIDAD"), 1, Integer.parseInt(request.getParameter("IDPERSONA")), request.getParameter("RESOLUCION"), ""); int insInvestigacion = interPersona.agregarInvestigacion(investigacion); out.println(insInvestigacion); break; case Constans.ELIMINARINVESTIGACION: int delInves = interPersona.eliminarInvestigacion(Integer.parseInt(request.getParameter("ID"))); out.println(delInves); break; case Constans.AGREGARPROYECCION: Proyeccion proyeccion = new Proyeccion(0, request.getParameter("ORANNO"), request.getParameter("ORACTIVIDAD"), request.getParameter("ORENTIDAD"), request.getParameter("ORINVERSION"), Integer.parseInt(request.getParameter("ORBENEFICIARIOS")), Integer.parseInt(request.getParameter("ORPARTICIPANTES")), request.getParameter("ORLUGAR"), Integer.parseInt(request.getParameter("ORTIPO")), 1, Integer.parseInt(request.getParameter("IDPERSONA")), ""); int insertProyeccion = interPersona.agregarProyeccion(proyeccion); out.println(insertProyeccion); break; case Constans.LISTARPROYECCION: ArrayList<Proyeccion> proyeccions = interPersona .listarProyeccion(Integer.parseInt(request.getParameter("ID")), request.getParameter("TIPO")); String jsonProyeccion = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(proyeccions); out.println(jsonProyeccion); break; case Constans.ELIMINARPROYECCION: int delProyeccion = interPersona.eliminarProyeccion(Integer.parseInt(request.getParameter("ID"))); out.println(delProyeccion); break; case Constans.ELIMINARRECONOCIMIENTO: int delReconocimiento = interPersona .eliminarReconocimiento(Integer.parseInt(request.getParameter("ID"))); out.println(delReconocimiento); break; case Constans.AGREGARRECONOCIMIENTO: Reconocimiento reconocimiento = new Reconocimiento(0, request.getParameter("FECHA"), request.getParameter("INSTITUCION"), request.getParameter("RECONOCIMIENTO"), request.getParameter("LUGAR"), Integer.parseInt(request.getParameter("TIPO")), request.getParameter("ACTIVIDAD"), 1, Integer.parseInt(request.getParameter("IDPERSONA")), request.getParameter("ANNO")); int insertReconocimiento = interPersona.agregarReconocimiento(reconocimiento); out.println(insertReconocimiento); break; case Constans.LISTARRECONOCIMIENTO: ArrayList<Reconocimiento> reconocimientos = interPersona.listarReconocimiento( Integer.parseInt(request.getParameter("IDPERSONA")), Integer.parseInt(request.getParameter("TIPO"))); String jsonReconocimiento = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(reconocimientos); out.println(jsonReconocimiento); break; case Constans.SUBIRDOCUMENTO: String urlSave = "C:\\Users\\Kelvin\\Documents\\NetBeansProjects\\Legajo\\web\\documents"; DiskFileItemFactory factory = new DiskFileItemFactory(); //factory.setSizeThreshold(2014); factory.setRepository(new File(urlSave)); ServletFileUpload upload = new ServletFileUpload(factory); try { List<FileItem> paList = upload.parseRequest(request); for (FileItem item : paList) { File file = new File(urlSave, "kelvin" + item.getName()); item.write(file); } out.println("Listo"); } catch (Exception e) { out.println("Execption: " + e.getMessage()); } break; case Constans.LISTARDOCUMENTO: ArrayList<Documento> documentos = interPersona .listarDocumento(Integer.parseInt(request.getParameter("IDPERSONA"))); String jsonDocumento = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(documentos); out.println(jsonDocumento); break; } }
From source file:nl.strohalm.cyclos.http.RequestProcessingFilter.java
@Override protected void execute(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException { // For performance reasons, these settings which will be used on every request are stored in the request context, not relying to the proxy // stored on the application context. See SettingsHelper.initialize() final LocalSettings localSettings = settingsService.getLocalSettings(); final AccessSettings accessSettings = settingsService.getAccessSettings(); request.setAttribute(SettingsHelper.LOCAL_KEY, localSettings); request.setAttribute(SettingsHelper.ACCESS_KEY, accessSettings); request.setAttribute("datePattern", messageHelper.getDatePatternDescription(localSettings.getDatePattern())); request.setAttribute("timePattern", messageHelper.getTimePatternDescription(localSettings.getTimePattern())); final String requestEncoding = request.getCharacterEncoding(); if (StringUtils.isEmpty(requestEncoding)) { request.setCharacterEncoding(localSettings.getCharset()); }/* w w w.ja v a2 s.c o m*/ response.setCharacterEncoding(localSettings.getCharset()); chain.doFilter(request, response); }
From source file:tw.com.sbi.agent.controller.AgentAuth.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); AgentAuthService agentAuthService = null; String groupId = request.getSession().getAttribute("group_id").toString(); String action = request.getParameter("action"); if ("selectAll".equals(action)) { try {//www . j a va2 s . com agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.getAgentAuthByGroupId(groupId); logger.debug("list.size(): " + list.size()); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("searchByAgentName".equals(action)) { try { String agentName = request.getParameter("agent_name"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.getAgentAuthByAgentName(groupId, agentName); logger.debug("list.size(): " + list.size()); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("searchByProductSpec".equals(action)) { try { String productSpec = request.getParameter("product_spec"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.getAgentAuthByProductSpec(groupId, productSpec); logger.debug("list.size(): " + list.size()); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("getProductInfo".equals(action)) { logger.debug("enter getProductInfo function"); try { agentAuthService = new AgentAuthService(); List<ProductVO> list = agentAuthService.getProductByGroupId(groupId); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("getAgentInfo".equals(action)) { // logger.debug("enter getAgentInfo function"); try { agentAuthService = new AgentAuthService(); List<AgentVO> list = agentAuthService.getAgentByGroupId(groupId); // logger.debug("getAgentInfo: " + list.toString()); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("insert".equals(action)) { logger.debug("enter agentauth insert method"); try { String agentId = request.getParameter("agent_id"); String productId = request.getParameter("product_id"); String regionCode = request.getParameter("region_code"); String authQuantity = request.getParameter("auth_quantity"); String saleQuantity = request.getParameter("sale_quantity"); String registerQuantity = request.getParameter("register_quantity"); String seed = request.getParameter("seed"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.addAgentAuth(groupId, agentId, productId, regionCode, authQuantity, saleQuantity, registerQuantity, seed); logger.debug("insert list: " + list.toString()); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("update".equals(action)) { logger.debug("enter agent update method"); try { String agentId = request.getParameter("agent_id"); String productId = request.getParameter("product_id"); String regionCode = request.getParameter("region_code"); String authQuantity = request.getParameter("auth_quantity"); String saleQuantity = request.getParameter("sale_quantity"); String registerQuantity = request.getParameter("register_quantity"); String seed = request.getParameter("seed"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.updateAgent(groupId, agentId, productId, regionCode, authQuantity, saleQuantity, registerQuantity, seed); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("delete".equals(action)) { try { String agentId = request.getParameter("agent_id"); String productId = request.getParameter("product_id"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.deleteAgentAuth(groupId, agentId, productId); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("gen_auth".equals(action)) { try { String agentId = request.getParameter("agent_id"); String productId = request.getParameter("product_id"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.genAuthCode(groupId, agentId, productId); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("autocomplete_agent".equals(action)) { try { String term = request.getParameter("term"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.getAgentAuthByAgentName(groupId, term); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } else if ("autocomplete_product".equals(action)) { try { String term = request.getParameter("term"); agentAuthService = new AgentAuthService(); List<AgentAuthVO> list = agentAuthService.getAgentAuthByProductSpec(groupId, term); Gson gson = new Gson(); String jsonStrList = gson.toJson(list); response.getWriter().write(jsonStrList); } catch (Exception e) { e.printStackTrace(); } } }