@RequestMapping(value = "/postResponse", method = RequestMethod.POST) public void postResponseToGroup( @ModelAttribute ParameterVO parameterVO, HttpServletRequest request, HttpServletResponse response, Model model) { String responseStatus = ApplicationConstants.GROUP_MESSAGE_POST_FAILURE; String responseMessage = ApplicationConstants.RESPONSE_FAILURE; JSONArray responseArray = new JSONArray(); JSONObject responseJson = new JSONObject(); try { // complete fetch basic objects from session dataAccessServiceManager.postResponse(parameterVO); if (parameterVO.isReponseStatus()) { responseMessage = ApplicationConstants.RESPONSE_SUCCESS; } response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); responseJson.put("message", responseMessage); responseArray.put(responseJson); response.getWriter().write(responseArray.toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * @param questionsVO * @param request * @param response * @param model */ @RequestMapping(value = "/postQuestionToGroup", method = RequestMethod.POST) public void postQuestionToGroup( @ModelAttribute DiscussionQuestionVO questionsVO, HttpServletRequest request, HttpServletResponse response, Model model) { String responseStatus = ApplicationConstants.GROUP_MESSAGE_POST_FAILURE; ParameterVO parameterVO = new ParameterVO(); try { boolean uploadFileFlag = false; parameterVO.setQuestionVO(questionsVO); // upload file code // /* MultipartHttpServletRequest requestUpdated = (MultipartHttpServletRequest) request; Iterator<String> itr = requestUpdated.getFileNames(); while (itr.hasNext()) { MultipartFile f = requestUpdated.getFile(itr.next()); if (f != null) { InputStream filecontent = f.getInputStream(); System.out.println(f.getName()); String filename = f.getName(); parameterVO.setEmailId(emailId); parameterVO.setListingType("question"); parameterVO.setFileName(filename); updateFileUploadDetails(parameterVO); int read = 0; File uploadFile = new File( parameterVO.getGeneratedFileName()); FileOutputStream fos = new FileOutputStream(uploadFile); System.out.println("parameterVO.getGeneratedFileName()::" + parameterVO.getGeneratedFileName()); final byte[] bytes = new byte[1024]; while ((read = filecontent.read(bytes)) != -1) { fos.write(bytes, 0, read); } //f.transferTo(uploadFile); parameterVO.setUploadedFile(uploadFile); uploadFileFlag = true; } } */ // complete fetch basic objects from session dataAccessServiceManager.postMessage(parameterVO); } catch (Exception e) { parameterVO.setReponseStatus(false); e.printStackTrace(); } JSONObject responseObject = new JSONObject(); responseObject.put("status", parameterVO.isReponseStatus()); // responseObject = createQuestionDetailResponseData(parameterVO); try { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.getWriter().write(responseObject.toString()); } catch (Exception e) { e.printStackTrace(); } }