List of usage examples for javax.servlet.http HttpServletRequest getRealPath
public String getRealPath(String path);
From source file:egpi.tes.ahv.servicio.MenuReporteJasper.java
/** * //from w w w . j a v a2 s. c om * @param request * @param response * @throws ServletException * @throws IOException */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String separador = System.getProperty("file.separator"); HttpSession session = request.getSession(true); client = new HttpClient(); pathaplicacion = "pathpublico"; properties = (Properties) session.getAttribute("propiedadesjasper"); if (request.getParameter("inputcontrol") != null && request.getParameter("inputcontrol").equals("1")) { System.out.println("VERIFICANDO LOS PARAMETROS DE PROCESO" + client); AutenticacionVO autenticacionVO = null; if (session.getAttribute("authVO") == null) { autenticacionVO = new AutenticacionVO(); autenticacionVO.setUsername(this.properties.getProperty("usuariopublico")); autenticacionVO.setPassword(this.properties.getProperty("password")); } else { autenticacionVO = (AutenticacionVO) session.getAttribute("authVO"); } if (validarUsuario(autenticacionVO)) { System.out.println("USUARIO VALIDADO CORRECTAMENTE...."); procesarControlesEntrada(request.getParameter("parentFolder")); } } else { sincronizarMenu.setPath(request.getRealPath("") + separador + properties.getProperty("pathinstalacion") + separador + "menu" + separador + "cache"); if (request.getParameter("cerrar") != null && request.getParameter("cerrar").equals("1")) { session.removeAttribute("authVO"); autenticacionVO = null; } obtenerDescriptorGeneral(); session.setAttribute("menuDeplegable", sincronizarMenu.menuDesplegable()); } PrintWriter out = response.getWriter(); out.println(obj); } catch (Exception e) { e.printStackTrace(); procesarError(response, e); } }
From source file:com.dwf.tastyroad.controller.RestaurantController.java
@RequestMapping(value = "/updateRestaurant", method = RequestMethod.POST) public ModelAndView updateRestaurantAction(@ModelAttribute("restaurant") Restaurant restaurant, HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("_______________________________________________"); System.out.println("==> /restaurant/updateRestaurant__call !!!"); System.out.println("_______________________________________________"); // CommonsMultipartResolver cmr = new CommonsMultipartResolver(); // String[] s1 = (String[])cmr.resolveMultipart(request).getParameterMap().get("resId"); // restaurant.setResId(Integer.parseInt(s1[0])); String fileDir1 = request.getRealPath("/") + "resources/img"; int max = 5 * 640 * 480; MultipartRequest mpr = new MultipartRequest(request, fileDir1, max, "UTF-8", new DefaultFileRenamePolicy()); restaurant.setResId(Integer.parseInt(mpr.getParameter("resId"))); System.out.println(restaurant.getResId()); System.out.println(restaurant); FTPTransfer transfer = new FTPTransfer(); transfer.delete(SERVER_IP, PORT, ID, PASSWORD, UPLOAD_DIR, restaurantService.getRestaurant(restaurant.getResId())); Enumeration formNames = mpr.getFileNames(); String fileInput = ""; String fileName = ""; String fileDir2 = ""; //ArrayList<File> fileList = new ArrayList<File>(); //HashMap<String, File> fileMap = new HashMap<String, File>(); while (formNames.hasMoreElements()) { System.out.println("============================"); fileInput = (String) formNames.nextElement(); System.out.println("fileInput : " + fileInput); fileName = mpr.getFilesystemName(fileInput); System.out.println("fileName : " + fileName); System.out.println("============================"); if (fileName != null) { System.out.println("if ?"); switch (fileInput) { case "imgSmall1": fileDir2 = fileDir1 + "/main"; System.out.println("fileDirectory : " + fileDir2); restaurant.setImgSmall1("main/" + fileName); System.out.println("restaurant.getImageSmall1 : " + restaurant.getImgSmall1()); //fileList.add(mpr.getFile(fileInput)); fileMap.put("imgSmall1", mpr.getFile(fileInput)); //System.out.println("getFile? ==> " + mpr.getFile(fileInput)); break; case "imgBig1": fileDir2 = fileDir1 + "/detail"; System.out.println("fileDirectory : " + fileDir2); restaurant.setImgBig1("detail/" + fileName); System.out.println("restaurant.getImageBig1 : " + restaurant.getImgBig1()); //fileList.add(mpr.getFile(fileInput)); fileMap.put("imgBig1", mpr.getFile(fileInput)); //System.out.println("getFile? ==> " + mpr.getFile(fileInput)); break; case "imgBig2": fileDir2 = fileDir1 + "/detail"; System.out.println("fileDirectory : " + fileDir2); restaurant.setImgBig2("detail/" + fileName); System.out.println("restaurant.getImageBig2 : " + restaurant.getImgBig2()); //fileList.add(mpr.getFile(fileInput)); fileMap.put("imgBig2", mpr.getFile(fileInput)); //System.out.println("getFile? ==> " + mpr.getFile(fileInput)); break; case "imgBig3": fileDir2 = fileDir1 + "/detail"; System.out.println("fileDirectory : " + fileDir2); restaurant.setImgBig3("detail/" + fileName); System.out.println("restaurant.getImageBig3 : " + restaurant.getImgBig3()); //fileList.add(mpr.getFile(fileInput)); fileMap.put("imgBig3", mpr.getFile(fileInput)); //System.out.println("getFile? ==> " + mpr.getFile(fileInput)); break; case "imgMenu": fileDir2 = fileDir1 + "/menu"; System.out.println("fileDirectory : " + fileDir2); restaurant.setImgMenu("menu/" + fileName); System.out.println("restaurant.getImageMenu : " + restaurant.getImgMenu()); //fileList.add(mpr.getFile(fileInput)); fileMap.put("imgMenu", mpr.getFile(fileInput)); //System.out.println("getFile? ==> " + mpr.getFile(fileInput)); break; }//endOfSwith } //endOfIf restaurant.setName(mpr.getParameter("name")); restaurant.setAddr(mpr.getParameter("addr")); restaurant.setPhone(mpr.getParameter("phone")); restaurant.setLicenseNo(mpr.getParameter("licenseNo")); restaurant.setGeoLat(Double.parseDouble(mpr.getParameter("geoLat"))); restaurant.setGeoLong(Double.parseDouble(mpr.getParameter("geoLong"))); restaurant.setCopyComment(mpr.getParameter("copyComment")); restaurant.setResCategory(Integer.parseInt(mpr.getParameter("resCategory"))); } //endOfWhile restaurantService.updateRestaurant(restaurant); boolean result = transfer.insert(SERVER_IP, PORT, ID, PASSWORD, UPLOAD_DIR, null, fileMap); //ftp ? ?, ? ? ? ? ?? . if (result == true) { set = fileMap.keySet();//from w w w . j a va 2s . c o m //set.toString(); //Console ?. ==> [imgSmall1, imgBig1, imgBig2, imgBig3, keys = set.toString().subSequence(1, set.toString().length() - 1).toString().split(", "); for (int i = 0; i < keys.length; i++) { System.out.println("Local File for ......"); File file1 = new File(fileMap.get(keys[i]).toString()); file1.delete(); if (file1.exists()) { System.out.println(" Failed......"); } else { System.out.println(" Ok!!!!!!"); } } //endOfForStatement } ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("restaurantViews/restaurantDetail"); modelAndView.addObject("restaurant", restaurantService.getRestaurant(restaurant.getResId())); return modelAndView; }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorInfoCheckReport(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); String id = request.getParameter("id").trim(); String wordType = request.getParameter("wordType"); List<CarSafetyRoportSource> list = serviceManager.getTractorInfoService() .tractorInfoReportFour(Integer.valueOf(id)); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir();// ww w .jav a 2 s . c om } String fineName = list.get(0).getLicense() + "_tractorInfoCheckReport_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/carSafetyReport.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorInfoTechnicReport(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); String id = request.getParameter("id").trim(); String wordType = request.getParameter("wordType"); List<TechnicalDataSource> list = serviceManager.getTractorInfoService() .tractorInfoReportThree(Integer.valueOf(id)); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir();//w w w .j av a2s. c o m } String fineName = list.get(0).getLicense() + "_tractorInfoTechnicReport_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/technicalData.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorInfoFlowReport(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); String id = request.getParameter("id").trim(); String wordType = request.getParameter("wordType"); List<TractorRegistrationRecordProcessSource> list = serviceManager.getTractorInfoService() .tractorInfoReportFive(Integer.valueOf(id)); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir();/* www. ja v a 2 s . c om*/ } String fineName = list.get(0).getLicense() + "_tractorInfoFlowReport_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/tractorRegistrationRecordProcess1.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void uploadPic(HttpServletRequest request, HttpServletResponse response) throws Exception { log.info("Someone come from ip address <" + request.getRemoteAddr() + ">"); log.info("reach upload picture"); boolean isMultipart = ServletFileUpload.isMultipartContent(request); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(request); FileItem fileItem = items.get(0);/*from w ww . ja v a2 s . c o m*/ String fileName = new File(fileItem.getName()).getName(); String mk = "[" + request.getSession().getAttribute("unitid").toString().trim() + "]" + (new Date()).toLocaleString().substring(0, 10).trim(); String filePath = request.getRealPath("//") + "//Public//Upload//" + mk + "//"; File dir = new File(filePath); if (!dir.exists()) { dir.mkdirs(); } File uploadFile = new File(filePath + "//" + fileName); fileItem.write(uploadFile); response.setContentType("text/html;charset=utf-8"); response.getWriter().write("{success: true,url:'./Public/Upload/" + mk + "/" + fileName + "'}"); log.info("?" + uploadFile.getName() + ""); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorInfoReport(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); String id = request.getParameter("id").trim(); String wordType = request.getParameter("wordType"); List<CarInfomationSource> list = serviceManager.getTractorInfoService() .tractorInfoReport(Integer.valueOf(id)); list.get(0).setPhotoUrl(/*w w w . j a va 2 s .c o m*/ request.getSession().getServletContext().getRealPath("/") + list.get(0).getPhotoUrl().substring(2)); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir(); } String fineName = list.get(0).getLicense() + "_tractorInfoReport_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/carInfomation.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorInfoRegisterReport(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); String id = request.getParameter("id").trim(); String wordType = request.getParameter("wordType"); List<TractorRegistrationAndTurnInSource> list = serviceManager.getTractorInfoService() .tractorInfoReportTwo(Integer.valueOf(id)); String fineName = list.get(0).getEngineno() + "_tractorInfoRegisterReport_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir();/* w w w.ja v a 2 s.com*/ } WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/tractorRegistrationAndTurnIn.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:Ynzc.YnzcAms.Controller.TractorInfoController.java
public void tractorEnregisterCertificate(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); HashMap map = new HashMap(); User user = (User) request.getSession().getAttribute("user"); UnitManage unit = (UnitManage) request.getSession().getAttribute("userUnit"); String wordType = request.getParameter("wordType"); String id = request.getParameter("id").trim(); List<TractorEnregisterCertificateReportSource> list = serviceManager.getTractorInfoService() .TractorEnregisterCertificate(Integer.valueOf(id)); String FileUrl = request.getRealPath("/") + "drivingLicenceUpload/" + DateTimeUtil.formatDate(DateTimeUtil.getNow()) + "/"; File file = new File(FileUrl); if (!file.isDirectory()) { file.mkdir();//from w w w . ja v a2s . c om } list.get(0).setRegistrationauthority_1(unit.getUseunit()); list.get(0).setRegisterdate_1(DateTimeUtil.formatDate(DateTimeUtil.getNow())); list.get(0).setRegistrationno_1("123456789"); // list.get(0).setOwner_2(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_2(unit.getUseunit()); // list.get(0).setRealcertificateno_2(unit.getUseunit()); // list.get(0).setRegistrationauthority_2(unit.getUseunit()); // list.get(0).setRegisterdate_2(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_2("2"); // // list.get(0).setOwner_3(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_3(unit.getUseunit()); // list.get(0).setRealcertificateno_3(unit.getUseunit()); // list.get(0).setRegistrationauthority_3(unit.getUseunit()); // list.get(0).setRegisterdate_3(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_3("3"); // // list.get(0).setOwner_4(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_4(unit.getUseunit()); // list.get(0).setRealcertificateno_4(unit.getUseunit()); // list.get(0).setRegistrationauthority_4(unit.getUseunit()); // list.get(0).setRegisterdate_4(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_4("4"); // // list.get(0).setOwner_5(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_5(unit.getUseunit()); // list.get(0).setRealcertificateno_5(unit.getUseunit()); // list.get(0).setRegistrationauthority_5(unit.getUseunit()); // list.get(0).setRegisterdate_5(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_5("5"); // // list.get(0).setOwner_6(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_6(unit.getUseunit()); // list.get(0).setRealcertificateno_6(unit.getUseunit()); // list.get(0).setRegistrationauthority_6(unit.getUseunit()); // list.get(0).setRegisterdate_6(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_6("6"); // // list.get(0).setOwner_7(list.get(0).getOwner_1()); // list.get(0).setRealcertificatetype_7(unit.getUseunit()); // list.get(0).setRealcertificateno_7(unit.getUseunit()); // list.get(0).setRegistrationauthority_7(unit.getUseunit()); // list.get(0).setRegisterdate_7(DateTimeUtil.formatDate(DateTimeUtil.getNow())); // list.get(0).setRegistrationno_7("7"); String fineName = list.get(0).getDriverinno() + "_tractorEnregisterCertificate_" + DateTimeUtil.formatDate(DateTimeUtil.getNow()); WordSet ws = serviceManager.getWordSetService().findWordSetByWordTypeandUnitid(wordType, user.getUnitid()); if (ws == null) { ws = new WordSet(); if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } else { if (!StringUtil.isNotNullEmptyStr(ws.getLeftMargin())) { ws.setLeftMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getRightMargin())) { ws.setRightMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getTopMargin())) { ws.setTopMargin("5"); } if (!StringUtil.isNotNullEmptyStr(ws.getBottomMargin())) { ws.setBottomMargin("5"); } } JasperReport report = IReportReCompile.getJasperReport( request.getRealPath("/") + "/Report/RegistrationInformation.jrxml", ws.getTopMargin(), ws.getBottomMargin(), ws.getLeftMargin(), ws.getRightMargin()); JRDataSource dataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, dataSource); String path = FileUrl + fineName + ".pdf"; JasperExportManager.exportReportToPdfFile(jasperPrint, path); response.getWriter() .write("{success:true,url:'" + path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\") + "'}"); System.out .println(path .replace(request.getRealPath("/"), "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + request.getServerPort() + request.getContextPath() + "/") .replace("\\", "\\\\")); }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.article.ArticleMultiController.java
public ModelAndView rss(HttpServletRequest request, HttpServletResponse response) { ModelAndView mav = new ModelAndView("articles/rss"); SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z"); String today = formatter.format(new Date()); List<Article> articleList = articleDao.getAllArticles(); int groupId;/*from w ww . j a va2 s. c o m*/ String copyright = "Copyright The University of West Bohemia"; String title = "EEGbase articles RSS feed"; String description = "Articles from EEGbase content management system"; String language = "en"; String link = domain + "/files/articles.rss"; Feed rssFeeder = new Feed(title, link, description, language, copyright, today); // Now add one example entry for (Article article : articleList) { FeedMessage feed = new FeedMessage(); feed.setTitle(article.getTitle()); feed.setDescription(article.getText().substring(0, (article.getText().length() > 200) ? 200 : article.getText().length() - 1)); feed.setAuthor(article.getPerson().getUsername()); feed.setGuid(""); feed.setLink(domain + "/articles/detail.html?articleId=" + article.getArticleId()); rssFeeder.getMessages().add(feed); } // Now write the file RSSFeedWriter writer = new RSSFeedWriter(rssFeeder, request.getRealPath("/") + "/files/articles.rss"); String rssFeedBuffer = ""; try { rssFeedBuffer = writer.write(); } catch (Exception e) { e.printStackTrace(); } mav.addObject("rssFeedBuffer", rssFeedBuffer); mav.addObject("articleList", articleList); mav.addObject("articleListTitle", "pageTitle.internalArticles"); mav = new ModelAndView("redirect:/files/articles.rss"); return mav; }