List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:fr.paris.lutece.util.http.SecurityUtil.java
/** * Write request variables into the dump stringbuffer * @param sb The dump stringbuffer/* w ww . j a v a2s .co m*/ * @param request The HTTP request */ private static void dumpVariables(StringBuffer sb, HttpServletRequest request) { dumpVariable(sb, "AUTH_TYPE", request.getAuthType()); dumpVariable(sb, "REQUEST_METHOD", request.getMethod()); dumpVariable(sb, "PATH_INFO", request.getPathInfo()); dumpVariable(sb, "PATH_TRANSLATED", request.getPathTranslated()); dumpVariable(sb, "QUERY_STRING", request.getQueryString()); dumpVariable(sb, "REQUEST_URI", request.getRequestURI()); dumpVariable(sb, "SCRIPT_NAME", request.getServletPath()); dumpVariable(sb, "LOCAL_ADDR", request.getLocalAddr()); dumpVariable(sb, "SERVER_PROTOCOL", request.getProtocol()); dumpVariable(sb, "REMOTE_ADDR", request.getRemoteAddr()); dumpVariable(sb, "REMOTE_HOST", request.getRemoteHost()); dumpVariable(sb, "HTTPS", request.getScheme()); dumpVariable(sb, "SERVER_NAME", request.getServerName()); dumpVariable(sb, "SERVER_PORT", String.valueOf(request.getServerPort())); }
From source file:de.highbyte_le.weberknecht.request.RequestWrapper.java
/** * read parameters from query string (HTTP GET) *//*from w w w .ja v a2s.co m*/ public static RequestWrapper createFromQueryString(HttpServletRequest request, String urlEncoding) throws UnsupportedEncodingException { RequestWrapper wrapper = new RequestWrapper(); String query = request.getQueryString(); if (query != null) { //use URL parameters from query string int startIndex = 0; int i; do { i = query.indexOf("&", startIndex); String nameValue; if (i != -1) { nameValue = query.substring(startIndex, i); } else { nameValue = query.substring(startIndex, query.length()); } int j = nameValue.indexOf("="); if (j != -1) { String name = URLDecoder.decode(nameValue.substring(0, j), urlEncoding); String value = URLDecoder.decode(nameValue.substring(j + 1, nameValue.length()), urlEncoding); wrapper.addParameter(name, value); logger.debug("createFromQueryString(HttpServletRequest, String) - found parameter: " + name + "=" + value); } startIndex = i + 1; } while (i != -1); } return wrapper; }
From source file:de.kurashigegollub.dev.gcatest.Utils.java
/** * // w w w.j a va 2s .co m * Will return a String with the request URL. * @param req The current HttpServletRequest. * @param includeServlet Will include the servlet name in the return value. * @param includePathInfo Will include the path and query parts in the return value (only added, if includeServlet is true as well). * @return */ // http://hostname.com:80/appname/servlet/MyServlet/a/b;c=123?d=789 public static String reconstructURL(HttpServletRequest req, boolean includeServlet, boolean includePathInfo) { String scheme = req.getScheme(); // http String serverName = req.getServerName(); // hostname.com int serverPort = req.getServerPort(); // 80 String contextPath = req.getContextPath(); // /appname String servletPath = req.getServletPath(); // /servlet/MyServlet String pathInfo = req.getPathInfo(); // /a/b;c=123 String queryString = req.getQueryString(); // d=789 // Reconstruct original requesting URL String url = scheme + "://" + serverName + ":" + serverPort + contextPath; if (includeServlet) { url += servletPath; if (includePathInfo) { if (pathInfo != null) { url += pathInfo; } if (queryString != null) { url += "?" + queryString; } } } return url; }
From source file:org.n52.web.common.RequestUtils.java
/** * Get the full request {@link URL} including the query parameter * * @return Request {@link URL} with query parameter * @throws IOException/*w ww .ja v a 2 s . c o m*/ * @throws URISyntaxException */ public static String resolveFullRequestUrl() throws IOException, URISyntaxException { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); URL url = new URL(request.getRequestURL().toString()); String scheme = url.getProtocol(); String userInfo = url.getUserInfo(); String host = url.getHost(); int port = url.getPort(); String path = request.getRequestURI(); if (path != null && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } String query = request.getQueryString(); URI uri = new URI(scheme, userInfo, host, port, path, query, null); return uri.toString(); }
From source file:com.zimbra.common.util.HttpUtil.java
public static Map<String, String> getURIParams(HttpServletRequest req) { return getURIParams(req.getQueryString()); }
From source file:fiftyone.mobile.detection.webapp.JavascriptProvider.java
/** * Responds with the JavaScript listing the featured properties and values. * @param request/*ww w. j av a 2 s. c om*/ * @param response * @throws IOException */ static void sendFeatureJavaScript(HttpServletRequest request, HttpServletResponse response) throws IOException { StringBuilder javascript = new StringBuilder("// Copyright 51 Degrees Mobile Experts Limited\r\n"); Dataset dataSet = WebProvider.getActiveProvider(request.getServletContext()).dataSet; final Map<String, String[]> results = WebProvider.getResult(request); List<String> features = new ArrayList<String>(); String query = request.getQueryString(); if (query == null) { for (Property property : dataSet.properties) { if (property.valueType != PropertyValueType.JAVASCRIPT) { getFeatureJavaScript(results, features, property); } } } else { Set<String> requestedProperties = new HashSet<String>(Arrays.asList(query.split("&"))); for (Property property : dataSet.properties) { if (property.valueType != PropertyValueType.JAVASCRIPT) { for (String name : requestedProperties) { if (name.equalsIgnoreCase(property.getName())) { getFeatureJavaScript(results, features, property); } } } } } javascript.append(String.format("var FODF={%s};", stringJoin(",", features))); sendJavaScript(request, response, WebProvider.getActiveProvider(request.getServletContext()).dataSet, javascript); }
From source file:com.zimbra.cs.servlet.ZimbraServlet.java
public static void proxyServletRequest(HttpServletRequest req, HttpServletResponse resp, Server server, AuthToken authToken) throws IOException, ServiceException { String uri = req.getRequestURI(); String qs = req.getQueryString(); if (qs != null) { uri += '?' + qs; }/* w ww. ja va 2 s . c o m*/ proxyServletRequest(req, resp, server, uri, authToken); }
From source file:com.icloud.framework.http.URLUtil.java
public static String getRequestUrlString(HttpServletRequest request) { String fullURL = ""; try {//from w ww.j a va2 s . co m String urlString = request.getRequestURL().toString(); String encodedRequestURL = URIUtil.encodePath(urlString); String queryString = request.getQueryString(); if (null == queryString) { fullURL = encodedRequestURL; } else { fullURL = encodedRequestURL + "?" + queryString; } } catch (URIException e1) { e1.printStackTrace(); } // http://robinkin:8280/jproxy-feeder/urlset/add // request.getPathTranslated(); // // // /home/liangwang/repo/mobile/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/jproxy/jproxy-feeder/urlset/add // // request.getPathInfo(); // // /jproxy-feeder/urlset/add // // request.getRequestURI(); // // /jproxy-feeder/urlset/add // // request.getContextPath(); // / // url=http%3A%2F%2Fnews.sohu.com%2F20040723%2Fn221153893.shtml&setname=test // HttpGet will translate a urlString into a URI, so , we should do the // check first, // if failed, call the encoder // try { // URI url = new URI(fullURL); // } catch (URISyntaxException e) { // try { // fullURL = URIUtil.encodePathQuery(fullURL); // } catch (URIException e1) { // e1.printStackTrace(); // } // } return fullURL; }
From source file:ispyb.client.common.util.FileUtil.java
/** * returns the value of the give param in the request * try to fix character '+' in the request (filename) * @param request//from w w w . j av a 2s .co m * @param param * @return */ public static String getRequestParameter(HttpServletRequest request, String param) { String value = request.getParameter(param); String query = request.getQueryString(); int id = query.indexOf(param); if (id != -1) { String paramValue = query.substring(1 + id + param.length()); int idA = paramValue.indexOf('&'); if (idA != -1) { paramValue = paramValue.substring(0, idA); } value = paramValue; } return value; }
From source file:com.zimbra.common.util.HttpUtil.java
/** Returns the full URL (including query string) associated with the * given <code>HttpServletRequest</code>. */ public static String getFullRequestURL(HttpServletRequest req) { if (req == null) return null; String uri = encodePath(req.getRequestURI()), qs = req.getQueryString(); if (qs != null) uri += '?' + qs; return uri;// w w w. ja v a 2 s . c o m }