List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:com.redhat.rhn.frontend.struts.RhnHelper.java
/** * If you need to a request parameter that may contain +++ * or other special characters that fails to fetch properly using * request.getParameter() you can use this method. * * @param request to fetch from/*ww w .java 2s .co m*/ * @param name of parameter to fetch * @return String value from request, null if not found. */ public static String getParameterWithSpecialCharacters(HttpServletRequest request, String name) { String queryString = request.getQueryString(); if (StringUtils.isEmpty(queryString)) { return null; } String[] pairs = StringUtils.split(queryString, "&"); for (int i = 0; i < pairs.length; i++) { String[] param = StringUtils.split(pairs[i], "="); String iname = param[0]; if (StringUtils.equals(name, iname) && param.length > 1) { String value = param[1]; return value; } } return null; }
From source file:nl.surfnet.coin.api.controller.AccessConfirmationController.java
/** * get a new URL based on the given request, with a lang= parameter set to the given language * * @param request HttpServletRequest// ww w. ja v a 2s . c o m * @param lang the language * @return String */ public static String getUrlWithLanguageParam(HttpServletRequest request, String lang) { String querystring; if (StringUtils.isBlank(request.getQueryString())) { querystring = "lang=" + lang; } else { String q = request.getQueryString(); List<String> newParams = new ArrayList<String>(); String[] params = q.split("&"); for (String param : params) { String[] keyvalue = param.split("="); if (!StringUtils.equals(keyvalue[0], "lang")) { newParams.add(keyvalue[0] + "=" + keyvalue[1]); } } newParams.add("lang=" + lang); querystring = StringUtils.join(newParams, "&"); } return "?" + querystring; }
From source file:eu.europeana.core.util.web.ControllerUtil.java
@SuppressWarnings("unchecked") public static String formatFullRequestUrl(HttpServletRequest request) { StringBuffer requestURL = request.getRequestURL(); if (request.getQueryString() != null) { requestURL.append("?").append(request.getQueryString()); } else if (request.getParameterMap() != null) { requestURL.append(formatParameterMapAsQueryString(request.getParameterMap())); }/*from www . jav a 2s . com*/ return requestURL.toString(); }
From source file:com.tang.util.RequestBeanKit.java
public static String getUrl(HttpServletRequest request) { String url = request.getRequestURL().toString(); String parmas = request.getQueryString(); if (StrKit.notBlank(parmas)) { url = url + "?" + parmas; }/*from w ww. j ava2 s . com*/ return url; }
From source file:com.hortonworks.example.util.Util.java
public static String getRequestUrl(HttpServletRequest request) { StringBuffer url = request.getRequestURL(); String query = request.getQueryString(); if (query != null) { url.append("?"); url.append(query);/*www . j a v a 2 s . co m*/ } String s = url.toString(); return s; }
From source file:com.pamarin.income.util.UrlUtils.java
private static String generateQuerystring() { HttpServletRequest request = getRequest(); String querystring = request.getQueryString(); if (querystring == null) { querystring = ""; } else {//from w w w. jav a2s. c om querystring = "?" + querystring; } return querystring; }
From source file:com.feilong.servlet.http.RequestUtilTemp.java
/** * ?./*from www.ja v a2s . c om*/ * * <p> * <span style="color:red">:url?,?,???</span> * </p> * * <p> * :({@link javax.servlet.ServletRequest#getParameter(String)},URI?,??) * </p> * * @param request * * @param paramName * ??? * @return ? * @deprecated ?? */ @Deprecated public static String getParameterAsItIsDecode(HttpServletRequest request, String paramName) { String returnValue = null; String queryString = request.getQueryString(); if (isNotNullOrEmpty(queryString)) { Map<String, String> map = ParamUtil.toSingleValueMap(queryString, null); return map.get(paramName); } return returnValue; }
From source file:com.mmd.mssp.util.WebUtil.java
public static String getHttpQueryParam(HttpServletRequest request, String key, String charset) throws UnsupportedEncodingException { String queryString = request.getQueryString(); if (!StringUtils.isAsciiPrintable(queryString)) {// ? ASCII ?? byte[] bytes = queryString.getBytes("iso-8859-1"); queryString = new String(bytes, charset); }//from ww w . j a v a 2 s .c om String val = StringUtil.searchKeyValue(queryString, key); if (val != null) { val = URLDecoder.decode(val, charset); } request.setAttribute("QueryDecodeCharset", val); return val; }
From source file:arena.utils.ServletUtils.java
public static String getURLFromRequest(HttpServletRequest request) { StringBuffer out = request.getRequestURL(); if (request.getQueryString() != null) { out.append("?").append(request.getQueryString()); }/*w w w. ja va 2s.c om*/ return out.toString(); }
From source file:org.apache.atlas.web.util.Servlets.java
public static String getDoAsUser(HttpServletRequest request) { if (StringUtils.isNoneEmpty(request.getQueryString())) { List<NameValuePair> list = URLEncodedUtils.parse(request.getQueryString(), UTF8_CHARSET); if (list != null) { for (NameValuePair nv : list) { if (DO_AS.equals(nv.getName())) { return nv.getValue(); }/*from ww w. j ava 2 s.c o m*/ } } } return null; }