List of usage examples for java.net URLDecoder decode
public static String decode(String s, Charset charset)
From source file:com.huawei.streaming.cql.LocalTaskCommons.java
/** * ?/*from w ww . ja v a 2 s . c om*/ * */ public static String setDir(String basePath) { String classPath = LocalTaskCommons.class.getResource("/").getPath(); try { classPath = URLDecoder.decode(classPath, DEFAULT_CHARSET); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return classPath + basePath + File.separator; }
From source file:com.mobilewallet.services.FeedbackService.java
@GET @Produces(MediaType.APPLICATION_JSON)//ww w . j a va 2s .com public Object feedBack(@Context HttpServletRequest request, @QueryParam("id") String eid, @QueryParam("feedType") String feedType, @QueryParam("text") String text, @QueryParam("email") String email) { log.info("User ID : " + eid); String decryptedUserId = MobileWalletID.getDecryptedUserId(eid); String userId = null; if (decryptedUserId != null) { try { userId = decryptedUserId.replace(Config.USER_ENCRYPTED_EXTENSION, ""); } catch (Exception ex) { } } try { if (userId != null) { User user = LoginBO.login(userId); JSONObject obj = new JSONObject(); if (user != null) { FeedBackBO.feedBack(user.getUserId(), URLDecoder.decode(feedType, "UTF-8"), URLDecoder.decode(text, "UTF-8"), request.getRemoteAddr(), user.getEmail()); SendMail sm = new SendMail(); try { //sm.sendHTMLMessage("Freeplus App Feed<noreply@amulyam.com>", "freeplusapp@gmail.com", user.getEmail(), user.getEmail() + ", " + feedType, "Email : " + user.getEmail() + "<br/>" + text); } catch (Exception ex) { } try { obj.put("sc", "Y"); } catch (Exception ex) { } return obj.toString(); } else { try { obj.put("user", "invalid"); } catch (Exception ex) { } return obj.toString(); } } } catch (Exception ex) { ex.printStackTrace(); } return new LoginBean(); }
From source file:gov.nih.nci.cabio.portal.portlet.RESTProxyServletController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { try {/*from www .jav a2 s .c o m*/ String relativeURL = request.getParameter("relativeURL"); if (relativeURL == null) { log.error("Null relativeURL parameter"); return null; } String qs = request.getQueryString(); if (qs == null) { qs = ""; } qs = qs.replaceFirst("relativeURL=(.*?)&", ""); qs = URLDecoder.decode(qs, "UTF-8"); String url = caBIORestURL + relativeURL + "?" + qs; log.info("Proxying URL: " + url); URI uri = new URI(url, false); HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(); method.setURI(uri); client.executeMethod(method); response.setContentType(method.getResponseHeader("Content-Type").getValue()); CopyUtils.copy(method.getResponseBodyAsStream(), response.getOutputStream()); } catch (Exception e) { throw new ServletException("Unable to connect to caBIO", e); } return null; }
From source file:com.jomp16.google.Google.java
public Google() throws IOException { String fileNameToFormat = "/lang/%s_%s.lang", fileNameFormatted = String.format(fileNameToFormat, System.getProperty("user.language"), System.getProperty("user.country")), jarPath = URLDecoder.decode( this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); URL url = new URL("jar:file:" + jarPath + "!" + fileNameFormatted); languageManager = new LanguageManager(url); }
From source file:max.hubbard.bettershops.Utils.ItemUtils.java
public static Map<String, Object> stringToMap(String input) { Map<String, Object> map = new HashMap<>(); String[] nameValuePairs = input.split("&"); for (String nameValuePair : nameValuePairs) { String[] nameValue = nameValuePair.split("="); try {//from ww w . j a v a 2 s . com map.put(URLDecoder.decode(nameValue[0], "UTF-8"), nameValue.length > 1 ? URLDecoder.decode(nameValue[1], "UTF-8") : ""); } catch (UnsupportedEncodingException e) { throw new RuntimeException("This method requires UTF-8 encoding support", e); } } return map; }
From source file:org.ala.spatial.web.services.SitesBySpeciesWSController.java
@RequestMapping(value = "/ws/sitesbyspecies", method = RequestMethod.POST) public @ResponseBody String processgeoq(HttpServletRequest req) { try {/*from w w w .j av a2 s . c o m*/ long currTime = System.currentTimeMillis(); String currentPath = AlaspatialProperties.getBaseOutputDir() + "output" + File.separator + "sitesbyspecies"; String qname = URLDecoder.decode(req.getParameter("qname"), "UTF-8").replace("__", "."); String speciesq = URLDecoder.decode(req.getParameter("speciesq"), "UTF-8").replace("__", "."); String area = req.getParameter("area"); String biocacheurl = URLDecoder.decode(req.getParameter("bs"), "UTF-8"); double gridsize = Double.parseDouble(req.getParameter("gridsize")); int movingAverageSize = Integer.parseInt(req.getParameter("movingaveragesize")); boolean occurrencedensity = req.getParameter("occurrencedensity") != null; boolean speciesdensity = req.getParameter("speciesdensity") != null; boolean sitesbyspecies = req.getParameter("sitesbyspecies") != null; String areasqkm = req.getParameter("areasqkm"); LayerFilter[] filter = null; SimpleRegion region = null; if (area != null && area.startsWith("ENVELOPE")) { filter = LayerFilter.parseLayerFilters(area); } else { region = SimpleShapeFile.parseWKT(area); } String pid = Long.toString(currTime); AnalysisJobSitesBySpecies sbs = new AnalysisJobSitesBySpecies(pid, currentPath, qname, speciesq, gridsize, region, filter, sitesbyspecies, occurrencedensity, speciesdensity, movingAverageSize, biocacheurl, areasqkm); StringBuffer inputs = new StringBuffer(); inputs.append("pid:").append(pid); inputs.append(";qname:").append(qname); inputs.append(";speciesq:").append(speciesq); inputs.append(";gridsize:").append(gridsize); inputs.append(";area:").append(area); if (occurrencedensity) { inputs.append(";occurrencedensity:true").append(area); } if (speciesdensity) { inputs.append(";speciesdensity:true").append(area); } if (sitesbyspecies) { inputs.append(";sitesbyspecies:true").append(area); } sbs.setInputs(inputs.toString()); AnalysisQueue.addJob(sbs); return pid; } catch (Exception e) { e.printStackTrace(System.out); } return ""; }
From source file:com.aliyun.odps.account.AliyunRequestSigner.java
public String getSignature(String resource, Request req) { try {//from ww w. j ava2 s. c o m resource = URLDecoder.decode(resource, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } String strToSign = SecurityUtils.buildCanonicalString(resource, req, "x-odps-"); if (log.isLoggable(Level.FINE)) { log.fine("String to sign: " + strToSign); } byte[] crypto = new byte[0]; try { crypto = SecurityUtils.hmacsha1Signature(strToSign.getBytes("UTF-8"), accessKey.getBytes()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } String signature = Base64.encodeBase64String(crypto).trim(); return "ODPS " + accessId + ":" + signature; }
From source file:org.hydracache.server.httpd.ParameterFetchRequestIntercepter.java
@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { String uri = request.getRequestLine().getUri(); String paramString = StringUtils.substringAfter(uri, "?"); String[] paramPairs = StringUtils.split(paramString, "&"); for (int i = 0; i < paramPairs.length; i++) { String p = paramPairs[i]; String[] paramPair = StringUtils.split(p, "="); if (paramPair != null && paramPair.length == 2) { String paramName = paramPair[0]; String paramValue = paramPair[1]; request.getParams().setParameter(paramName, URLDecoder.decode(paramValue, "UTF-8")); }//from ww w .j a va 2s . co m } }
From source file:com.codenjoy.dojo.web.controller.GameDataController.java
@RequestMapping(value = "/settings/{gameType}/{key}", method = RequestMethod.POST) public @ResponseBody String set(@PathVariable("gameType") String gameType, @PathVariable("key") String key, @RequestBody String value) { try {/* w w w .j a v a 2 s. c o m*/ gameData.set(gameType, key, URLDecoder.decode(value, "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return "{}"; }
From source file:com.sniper.springmvc.utils.CookieUtils.java
/** * Cookie//from w ww. ja va 2 s .com * * @param request * * @param response * ? * @param name * ?? * @param isRemove * ? * @return */ public static String getCookie(HttpServletRequest request, HttpServletResponse response, String name, boolean isRemove) { String value = null; Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(name)) { try { value = URLDecoder.decode(cookie.getValue(), "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (isRemove) { cookie.setMaxAge(0); response.addCookie(cookie); } } } } return value; }