List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:eionet.util.SecurityUtil.java
/** * * @param request/* w w w.ja v a 2s. c om*/ * @return */ public static String buildAfterLoginURL(HttpServletRequest request) { String requestUri = (String) request.getAttribute("javax.servlet.forward.request_uri"); if (requestUri == null) { requestUri = request.getRequestURL().toString(); } String queryString = (String) request.getAttribute("javax.servlet.forward.query_string"); if (queryString == null) { queryString = request.getQueryString(); } return queryString == null ? requestUri : requestUri + "?" + queryString; }
From source file:jp.go.nict.langrid.servicecontainer.handler.jsonrpc.servlet.JsonRpcServlet.java
private static String getServiceName(HttpServletRequest req) { String uri = req.getRequestURL().toString(); String serviceName = uri.substring(uri.lastIndexOf('/') + 1); String queryStr = req.getQueryString(); if (queryStr != null) { try {/* w w w . j av a 2s . c o m*/ Map<String, String> params = URLUtil.getQueryParameters(new URL(uri + "?" + queryStr)); String sn = params.get("serviceName"); if (sn != null) { serviceName = sn; } } catch (MalformedURLException e) { } } return serviceName; }
From source file:de.metas.ui.web.config.ServletLoggingFilter.java
private static final String extractRequestInfo(final ServletRequest request) { String requestInfo;/*from w w w.ja v a 2s . co m*/ if (request instanceof HttpServletRequest) { final HttpServletRequest httpRequest = (HttpServletRequest) request; final String urlStr = httpRequest.getRequestURL().toString(); URI uri; try { uri = new URI(urlStr); } catch (final URISyntaxException e) { uri = null; } String path = null; if (uri != null) { path = uri.getPath(); } if (path == null) { path = urlStr; } final String queryString = httpRequest.getQueryString(); requestInfo = path + (queryString != null ? "?" + queryString : ""); } else { requestInfo = request.toString(); } return requestInfo; }
From source file:com.log4ic.compressor.utils.HttpUtils.java
/** * ?/* w ww .j ava 2 s.co m*/ * * @param request * @return */ public static String getQueryString(HttpServletRequest request) { //?JSP?include? Object queryString = request.getAttribute("javax.servlet.include.query_string"); if (queryString == null) { //?JSP?forward? queryString = request.getAttribute("javax.servlet.forward.query_string"); } if (queryString != null) { return queryString.toString(); } return request.getQueryString(); }
From source file:org.impalaframework.extension.mvc.util.RequestModelHelper.java
/** * //from w w w .j ava 2s . co m * @param logger * @param request */ public static void maybeDebugRequest(Log logger, HttpServletRequest request) { if (logger.isDebugEnabled()) { logger.debug("#####################################################################################"); logger.debug("---------------------------- Request details ---------------------------------------"); logger.debug("Request context path: " + request.getContextPath()); logger.debug("Request path info: " + request.getPathInfo()); logger.debug("Request path translated: " + request.getPathTranslated()); logger.debug("Request query string: " + request.getQueryString()); logger.debug("Request servlet path: " + request.getServletPath()); logger.debug("Request request URI: " + request.getRequestURI()); logger.debug("Request request URL: " + request.getRequestURL()); logger.debug("Request session ID: " + request.getRequestedSessionId()); logger.debug("------------------------------------------------ "); logger.debug("Parameters ------------------------------------- "); final Enumeration<String> parameterNames = request.getParameterNames(); Map<String, String> parameters = new TreeMap<String, String>(); while (parameterNames.hasMoreElements()) { String name = parameterNames.nextElement(); String value = request.getParameter(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } parameters.put(name, value); } //now output final Set<String> parameterKeys = parameters.keySet(); for (String key : parameterKeys) { logger.debug(key + ": " + parameters.get(key)); } logger.debug("------------------------------------------------ "); Map<String, Object> attributes = new TreeMap<String, Object>(); logger.debug("Attributes ------------------------------------- "); final Enumeration<String> attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String name = attributeNames.nextElement(); Object value = request.getAttribute(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } attributes.put(name, value); } //now output final Set<String> keys = attributes.keySet(); for (String name : keys) { Object value = attributes.get(name); logger.debug(name + ": " + (value != null ? value.toString() : value)); } logger.debug("------------------------------------------------ "); logger.debug("#####################################################################################"); } else { if (logger.isInfoEnabled()) { logger.info( "#####################################################################################"); logger.info("Request query string: " + request.getQueryString()); logger.info("Request request URI: " + request.getRequestURI()); logger.info( "#####################################################################################"); } } }
From source file:com.acciente.commons.htmlform.Parser.java
private static Map parseGETParams(HttpServletRequest oRequest) throws ParserException, IOException { Map oGETParams;//from w w w .j ava2 s . com StringReader oQueryStringReader = null; try { oQueryStringReader = new StringReader(oRequest.getQueryString()); oGETParams = Parser.parseForm(oQueryStringReader, true); } finally { if (oQueryStringReader != null) { oQueryStringReader.close(); } } return oGETParams; }
From source file:com.easou.common.util.CommonUtils.java
/** * Safe method for retrieving a parameter from the request without * disrupting the reader UNLESS the parameter actually exists in the query * string./*from w ww. j av a2s.c o m*/ * <p> * Note, this does not work for POST Requests for "logoutRequest". It works * for all other CAS POST requests because the parameter is ALWAYS in the * GET request. * <p> * If we see the "logoutRequest" parameter we MUST treat it as if calling * the standard request.getParameter. * * @param request * the request to check. * @param parameter * the parameter to look for. * @return the value of the parameter. */ public static String safeGetParameter(final HttpServletRequest request, final String parameter) { if ("POST".equals(request.getMethod()) && "logoutRequest".equals(parameter)) { LOG.debug( "safeGetParameter called on a POST HttpServletRequest for LogoutRequest. Cannot complete check safely. Reverting to standard behavior for this Parameter"); return request.getParameter(parameter); } return request.getQueryString() == null || request.getQueryString().indexOf(parameter) == -1 ? null : request.getParameter(parameter); }
From source file:net.sourceforge.fenixedu.presentationTier.util.ExceptionInformation.java
private static String getRequestFullUrl(HttpServletRequest request) { StringBuffer requestFullURL = request.getRequestURL(); String queryString = request.getQueryString(); return queryString == null ? requestFullURL.toString() : requestFullURL.append('?').append(queryString).toString(); }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTagUtil.java
private static String makeNonPagedLink(HttpServletRequest request, String listName) { String url = (String) request.getAttribute("parentUrl"); String queryString = request.getQueryString(); if (queryString != null && queryString.length() > 0) { url += "?"; for (StringTokenizer strtok = new StringTokenizer(queryString, "&"); strtok.hasMoreTokens();) { String token = strtok.nextToken(); if (token.indexOf(listName) > -1 && token.indexOf("_page=") > -1) { continue; }/*from ww w . j a va2 s. c o m*/ if (url.endsWith("?")) { url += token; } else { url = url + "&" + token; } } } return url; }
From source file:net.siegmar.japtproxy.JaptProxy.java
public static String getURL(HttpServletRequest req, boolean serverOnly, Configuration configuration) { String scheme = req.getScheme(); // http String serverName = req.getServerName(); // hostname.com // do we have a remap for this serverName?? String remap = configuration.getRemap(serverName); if (remap != null) { serverName = remap;//from w ww .j a va 2 s. c om } int serverPort = req.getServerPort(); // 80 String contextPath = req.getContextPath(); // /mywebapp String servletPath = req.getServletPath(); // /servlet/MyServlet String pathInfo = req.getPathInfo(); // /a/b;c=123 String queryString = req.getQueryString(); // d=789 // Reconstruct original requesting URL StringBuilder url = new StringBuilder(); url.append(scheme).append("://").append(serverName); if (serverPort != 80 && serverPort != 443) { url.append(":").append(serverPort); } if (serverOnly) return url.toString(); url.append(contextPath).append(servletPath); if (pathInfo != null) { url.append(pathInfo); } if (queryString != null) { url.append("?").append(queryString); } return url.toString(); }