List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:net.sourceforge.fenixedu.presentationTier.util.ExceptionInformation.java
private void mappingContextAppend(HttpServletRequest request, final StringBuilder exceptionInfo) { String query = request.getQueryString(); setRequestURI(request.getRequestURI()); setRequestURL(request.getRequestURL().toString()); setRequestFullUrl(getRequestFullUrl(request)); setQueryString(query);/*w w w.j av a 2s.c o m*/ setRequestMethod(request.getMethod()); setRequestParameters(getRequestParameters(request)); exceptionInfo.append("[RequestURI] ").append(request.getRequestURI()).append("\n"); exceptionInfo.append("[RequestURL] ").append(request.getRequestURL()).append("\n"); exceptionInfo.append("[QueryString] ").append(request.getQueryString()).append("\n"); exceptionInfo.append("[Method] ").append(request.getMethod()).append('\n'); if (request.getAttribute(PresentationConstants.ORIGINAL_MAPPING_KEY) != null) { ActionMapping mapping = (ActionMapping) request .getAttribute(PresentationConstants.ORIGINAL_MAPPING_KEY); setActionMapping(mapping); exceptionInfo.append("[Path] ").append(mapping.getPath()).append("\n"); exceptionInfo.append("[Name] ").append(mapping.getName()).append("\n"); } else { exceptionInfo.append("[Path|Name] impossible to get (exception through UncaughtExceptionFilter)\n"); } }
From source file:com.ibm.jaggr.service.impl.transport.AbstractHttpTransport.java
/** * This method checks the request for the has conditions which may either be contained in URL * query arguments or in a cookie sent from the client. * //from w w w. j av a 2 s .c om * @return The has conditions from the request. * @throws UnsupportedEncodingException */ protected static String getHasConditionsFromRequest(HttpServletRequest request) throws IOException { String ret = null; if (request.getParameter(FEATUREMAPHASH_REQPARAM) != null) { // The cookie called 'has' contains the has conditions Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; ret == null && i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookie.getName().equals(FEATUREMAP_REQPARAM) && cookie.getValue() != null) { ret = URLDecoder.decode(cookie.getValue(), "US-ASCII"); //$NON-NLS-1$ break; } } } if (ret == null) { if (log.isLoggable(Level.WARNING)) { StringBuffer url = request.getRequestURL(); if (url != null) { // might be null if using mock request for unit testing url.append("?").append(request.getQueryString()).toString(); //$NON-NLS-1$ log.warning(MessageFormat.format(Messages.AbstractHttpTransport_0, new Object[] { url, request.getHeader("User-Agent") })); //$NON-NLS-1$ } } } } else ret = request.getParameter(FEATUREMAP_REQPARAM); return ret; }
From source file:com.laxser.blitz.web.impl.thread.ActionEngine.java
@Override public int isAccepted(HttpServletRequest request) { if (paramExistenceChecker.length == 0) { //??1 return 1; }/*w w w . j a v a2s . c o m*/ int total = 0; Map<String, String[]> params = resolveQueryString(request.getQueryString()); for (ParamExistenceChecker checker : paramExistenceChecker) { int c = checker.check(params); if (c == -1) { //-1?? if (logger.isDebugEnabled()) { logger.debug("Accepted check not passed by " + checker.toString()); } return -1; } //FIXME ?????? //????? total += c; } return total; }
From source file:org.dataone.proto.trove.mn.rest.base.AbstractWebController.java
protected void debugRequest(HttpServletRequest request) { /* see values with just a plain old request object being sent through */ logger.debug("request RequestURL: " + request.getRequestURL()); logger.debug("request RequestURI: " + request.getRequestURI()); logger.debug("request PathInfo: " + request.getPathInfo()); logger.debug("request PathTranslated: " + request.getPathTranslated()); logger.debug("request QueryString: " + request.getQueryString()); logger.debug("request ContextPath: " + request.getContextPath()); logger.debug("request ServletPath: " + request.getServletPath()); logger.debug("request toString:" + request.toString()); Enumeration<String> attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String attributeName = attributeNames.nextElement(); logger.debug("request " + attributeName + ": " + request.getAttribute(attributeName)); }//from w w w. ja va 2 s. c om /* values of proxyServletWrapper request object to be sent through */ logger.info(""); /* uncomment to see what the parameters of servlet passed in are */ Map<String, String[]> parameterMap = request.getParameterMap(); for (Object key : parameterMap.keySet()) { String[] values = parameterMap.get((String) key); for (int i = 0; i < values.length; ++i) { logger.info("request ParameterMap: " + (String) key + " = " + values[i]); } } logger.debug(""); }
From source file:be.milieuinfo.core.proxy.controller.ProxyServlet.java
private String rewriteUrlFromRequest(HttpServletRequest servletRequest) { StringBuilder uri = new StringBuilder(500); uri.append(this.targetUri.toString()); // Handle the path given to the servlet if (servletRequest.getPathInfo() != null) {//ex: /my/path.html uri.append(servletRequest.getPathInfo()); }//from w ww .j a v a 2s .c o m // Handle the query string String queryString = servletRequest.getQueryString();//ex:(following '?'): name=value&foo=bar#fragment if (queryString != null && queryString.length() > 0) { uri.append('?'); int fragIdx = queryString.indexOf('#'); String queryNoFrag = (fragIdx < 0 ? queryString : queryString.substring(0, fragIdx)); uri.append(encodeUriQuery(queryNoFrag)); if (fragIdx >= 0) { uri.append('#'); uri.append(encodeUriQuery(queryString.substring(fragIdx + 1))); } } return uri.toString(); }
From source file:org.tsm.concharto.web.filter.LoginFilter.java
private boolean isAuthenticated(HttpServletRequest httpRequest) { HttpSession session = httpRequest.getSession(); if (log.isDebugEnabled()) { log.debug("auth login filter"); }//ww w .j a v a 2 s . c o m //TODO reliance on session may be a problem for scalability if (!AuthHelper.isUserInSession(httpRequest)) { //save the target so we can get there after authentication StringBuffer redirect = new StringBuffer(httpRequest.getRequestURI()); //no cookie set, we need to go to the login screen if (!StringUtils.isEmpty(httpRequest.getQueryString())) { redirect.append('?').append(httpRequest.getQueryString()); } session.setAttribute(AuthConstants.SESSION_AUTH_TARGET_URI, redirect.toString()); return false; } else { return true; } }
From source file:com.sap.cloudlabs.connectivity.proxy.ProxyServlet.java
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.debug(">>>>>>>>>>>> start request"); // read destination and relative service path from URL String queryString = request.getQueryString(); String destinationName = getDestinationFromUrl(request.getServletPath()); String pathInfo = null;//from w w w. j a va 2s .co m int contextPathLength = request.getContextPath().length(); int servletPathLength = request.getServletPath().length(); if (request.getRequestURI().endsWith(destinationName)) { pathInfo = ""; } else { pathInfo = request.getRequestURI().substring(servletPathLength + contextPathLength); } String urlToService = getRelativePathFromUrl(pathInfo, queryString); // get the http client for the destination HttpDestination dest = getDestination(destinationName); HttpClient httpClient = null; try { httpClient = dest.createHttpClient(); // create request to targeted backend service HttpRequestBase backendRequest = getBackendRequest(request, urlToService); // execute the backend request HttpResponse backendResponse = httpClient.execute(backendRequest); String rewriteUrl = getDestinationUrl(dest); String proxyUrl = getProxyUrl(request); // process response from backend request and pipe it to origin response of client processBackendResponse(request, response, backendResponse, proxyUrl, rewriteUrl); } catch (DestinationException e) { throw new ServletException(e); } finally { if (httpClient != null) { httpClient.getConnectionManager().shutdown(); } LOGGER.debug(">>>>>>>>>>>> end request"); } }
From source file:org.redhat.jboss.httppacemaker.ProxyServlet.java
/** Reads the request URI from {@code servletRequest} and rewrites it, considering {@link * #targetUri}. It's used to make the new request. *//*from w ww . j av a 2s. c o m*/ protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) { StringBuilder uri = new StringBuilder(500); uri.append(this.targetUri.toString()); // Handle the path given to the servlet if (servletRequest.getPathInfo() != null) {//ex: /my/path.html uri.append(encodeUriQuery(servletRequest.getPathInfo())); } // Handle the query string String queryString = servletRequest.getQueryString();//ex:(following '?'): name=value&foo=bar#fragment if (queryString != null && queryString.length() > 0) { uri.append('?'); int fragIdx = queryString.indexOf('#'); String queryNoFrag = (fragIdx < 0 ? queryString : queryString.substring(0, fragIdx)); uri.append(encodeUriQuery(queryNoFrag)); if (fragIdx >= 0) { uri.append('#'); uri.append(encodeUriQuery(queryString.substring(fragIdx + 1))); } } return uri.toString(); }
From source file:org.mitre.dsmiley.httpproxy.DynamicProxyServlet.java
/** Reads the request URI from {@code servletRequest} and rewrites it, considering targetUri. * It's used to make the new request.// w w w .j a v a2s . c o m */ protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) { StringBuilder uri = new StringBuilder(500); uri.append(getTargetUri(servletRequest)); // Handle the query string & fragment String queryString = servletRequest.getQueryString();//ex:(following '?'): name=value&foo=bar#fragment String fragment = null; //split off fragment from queryString, updating queryString if found if (queryString != null) { int fragIdx = queryString.indexOf('#'); if (fragIdx >= 0) { fragment = queryString.substring(fragIdx + 1); queryString = queryString.substring(0, fragIdx); } } queryString = rewriteQueryStringFromRequest(servletRequest, queryString); if (queryString != null && queryString.length() > 0) { uri.append('?'); uri.append(encodeUriQuery(queryString)); } if (doSendUrlFragment && fragment != null) { uri.append('#'); uri.append(encodeUriQuery(fragment)); } return uri.toString(); }
From source file:uk.ac.ebi.phenotype.web.proxy.ExternalUrlConfiguratbleProxyServlet.java
private String rewriteUrlFromRequest(HttpServletRequest servletRequest) { StringBuilder uri = new StringBuilder(500); uri.append(this.targetUri.toString()); // Handle the path given to the servlet if (servletRequest.getPathInfo() != null) {// ex: /my/path.html uri.append(servletRequest.getPathInfo()); }//from w ww. j av a 2 s. co m // Handle the query string String queryString = servletRequest.getQueryString();// ex:(following // '?'): // name=value&foo=bar#fragment if (queryString != null && queryString.length() > 0) { uri.append('?'); int fragIdx = queryString.indexOf('#'); String queryNoFrag = (fragIdx < 0 ? queryString : queryString.substring(0, fragIdx)); uri.append(encodeUriQuery(queryNoFrag)); if (fragIdx >= 0) { uri.append('#'); uri.append(encodeUriQuery(queryString.substring(fragIdx + 1))); } } return uri.toString().replaceAll(" ", "%20"); }