List of usage examples for javax.servlet.http HttpServletRequest getRealPath
public String getRealPath(String path);
From source file:org.openmrs.module.custombranding.CustomBrandingUtils.java
private static String getDefaultThemePath(HttpServletRequest request) { String theme = RequestContextUtils.getTheme(request).getName(); String fileSysLocation = request.getRealPath("/") + "WEB-INF" + File.separator; String themeFilePath = ""; if (versionGreater(OpenmrsConstants.OPENMRS_VERSION_SHORT, "1.6")) { themeFilePath = fileSysLocation + "classes" + File.separator + "themes" + File.separator + "defaults.properties"; } else {//from w w w . j a va2 s. co m themeFilePath = fileSysLocation + "classes" + File.separator + "standard_" + theme + ".properties"; } return themeFilePath; }
From source file:org.openmrs.module.custombranding.CustomBrandingUtils.java
private static String getThemePath(HttpServletRequest request) { String theme = RequestContextUtils.getTheme(request).getName(); String fileSysLocation = request.getRealPath("/") + "WEB-INF" + File.separator; String themeFilePath = ""; if (versionGreater(OpenmrsConstants.OPENMRS_VERSION_SHORT, "1.6")) { if (theme.trim().equals("")) { theme = "defaults"; }/*from w w w . ja va2 s. c o m*/ themeFilePath = fileSysLocation + "classes" + File.separator + "themes" + File.separator + theme + ".properties"; } else { themeFilePath = fileSysLocation + "classes" + File.separator + "standard_" + theme + ".properties"; } return themeFilePath; }
From source file:com.nary.io.FileUtils.java
/** * This method should be used instead of HttpServletRequest.getRealPath() * /*from ww w.j a va 2s. c om*/ * If we can't get the path, then lets drop to use the ServletContext as a final resort */ @SuppressWarnings("deprecation") public static String getRealPath(HttpServletRequest request, String path) { path = path.replace('\\', '/'); String realPath = request.getRealPath(path); if (realPath == null) { // WebLogic packed WAR realPath = getWebLogicRealPath(path); if (realPath == null) { realPath = cfEngine.thisServletContext.getRealPath(path); } } return realPath; }
From source file:md.ibanc.rm.controllers.mvc.MultiActionControllers.java
@RequestMapping(value = "/sendMail") public String sendMail(HttpServletRequest request) { String str = request.getRealPath("/"); System.out.println(" SaveDevicesDetailsThread string = " + str); SingInOutSessions singInOutSessions = singInOutSessionsService.findById(57); // SendMailNewDevices sendMailNewDevices = new SendMailNewDevices(singInOutSessions, str); //sendMailNewDevices.sendMail(); return ""; }
From source file:com.pm.myshop.controller.FilesController.java
@RequestMapping("/pictures/{thumb}/{fileName}") @ResponseBody//from w w w. ja va2 s .c o m public void viewFiles(@PathVariable("fileName") String fileName, @PathVariable("thumb") String thumb, HttpServletRequest request, HttpServletResponse response) throws IOException { try { String path = request.getRealPath("/"); response.setContentType("image/jpeg"); InputStream inputStream = new FileInputStream(path + "../../files/" + thumb + "/" + fileName + ".jpg"); IOUtils.copy(inputStream, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { System.out.println(ex.getMessage()); response.getWriter().print("File Not Found"); } }
From source file:org.wp.spring.php.view.PHPView.java
private Path getPath(HttpServletRequest req) { String scriptPath = getUrl(); if (_context.getScriptPath() == null || _context.getScriptPath().isEmpty()) { scriptPath = req.getRealPath(scriptPath); } else {// ww w. j a v a 2 s .c o m scriptPath = _context.getScriptPath() + scriptPath; } _log.info(new FilePath(scriptPath)); return new FilePath(scriptPath); }
From source file:com.neu.controller.OutcomeController.java
@RequestMapping(value = "/outcome.htm", method = RequestMethod.GET, headers = "Accept=*/*", produces = "application/json") @ResponseStatus(HttpStatus.OK)/*from w w w . j ava 2 s. com*/ public @ResponseBody String searchresult(HttpServletRequest request) throws Exception { System.out.println("in drugsearch controller"); String action = request.getParameter("action"); List<DrugOutcome> outcomes; String csvFile = "Merge.csv"; String rpath = request.getRealPath("/"); rpath = rpath + "/dataFiles/" + csvFile; Pattern pattern = Pattern.compile(","); BufferedReader in = new BufferedReader(new FileReader(rpath)); outcomes = in.lines().skip(1).map(line -> { String[] x = pattern.split(line); return new DrugOutcome(x[3], x[20], x[7], x[6], x[8], x[13], x[4], x[5]); }).collect(Collectors.toList()); ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationConfig.Feature.INDENT_OUTPUT); mapper.writeValue(System.out, outcomes); // Drugs drug=new Drugs("AZ","sn"); return mapper.writeValueAsString(outcomes); }
From source file:com.neu.controller.SearchController.java
@RequestMapping(value = "/search.htm", method = RequestMethod.GET, headers = "Accept=*/*", produces = "application/json") @ResponseStatus(HttpStatus.OK)//from ww w . ja va 2 s .com public @ResponseBody String searchresult(HttpServletRequest request) throws Exception { System.out.println("in drugsearch controller"); String action = request.getParameter("action"); List<Drugs> drugs; String csvFile = "UserSearch.csv"; String rpath = request.getRealPath("/"); rpath = rpath + "/dataFiles/" + csvFile; Pattern pattern = Pattern.compile(","); BufferedReader in = new BufferedReader(new FileReader(rpath)); drugs = in.lines().skip(1).map(line -> { String[] x = pattern.split(line); return new Drugs(x[0], x[3]); }).collect(Collectors.toList()); ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationConfig.Feature.INDENT_OUTPUT); mapper.writeValue(System.out, drugs); // Drugs drug=new Drugs("AZ","sn"); return mapper.writeValueAsString(drugs); }
From source file:org.openmrs.module.custombranding.web.controller.CustomBrandingController.java
@Override protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { String fileSysLocation = request.getRealPath("/"); String messageFileLocation = fileSysLocation + File.separator + "WEB-INF" + File.separator + "messages.properties"; String messageNewLocation = fileSysLocation + File.separator + "images" + File.separator + "messages.properties"; FileUtils.copyFile(new File(messageFileLocation), new File(messageNewLocation)); Properties themeProps = CustomBrandingUtils.getThemeProperties(request); largeLogo = themeProps.getProperty("image.logo.large"); smallLogo = themeProps.getProperty("image.logo.small"); textLogo = themeProps.getProperty("image.logo.text.small"); orgUrl = themeProps.getProperty("url.organization"); favicon = themeProps.getProperty("favicon"); icon = themeProps.getProperty("favicon.png"); Map<String, String> map = new HashMap<String, String>(); map.put("largeLogo", largeLogo); map.put("smallLogo", smallLogo); map.put("textLogo", textLogo); map.put("orgUrl", orgUrl); map.put("favicon", favicon); map.put("icon", icon); return map;/*from w w w . j a v a2 s. c om*/ }
From source file:com.provenance.cloudprovenance.policyhandler.ws.support.PolicyRequestProcessor.java
private void storeRequest(String requestId, String requestContent, HttpServletRequest request) throws IOException { File requestFile = new File( request.getRealPath(cProvlRequestDirectoryPath) + "/request" + requestId + "-cprovl.xml"); logger.info("File URI: " + requestFile.getAbsolutePath()); requestFile.createNewFile();//from ww w . ja v a2 s .c o m FileWriter fWritter = new FileWriter(requestFile); fWritter.write(requestContent); fWritter.close(); }