Example usage for javax.servlet.http HttpServletRequest getQueryString

List of usage examples for javax.servlet.http HttpServletRequest getQueryString

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getQueryString.

Prototype

public String getQueryString();

Source Link

Document

Returns the query string that is contained in the request URL after the path.

Usage

From source file:org.davidmendoza.esu.web.ComunicaController.java

@RequestMapping(method = RequestMethod.GET)
public String comunica(HttpServletRequest request) {
    log.info("Redirecting: /comunica?{}", request.getQueryString());
    return "redirect:/comparte";
}

From source file:info.magnolia.module.servletsanity.support.ServletAssert.java

public static void printRequestInfo(HttpServletRequest request, HttpServletResponse response, String location)
        throws IOException {
    append("");/*from w ww.  j  a v  a  2 s.c om*/
    append("");
    append("###################################");
    append("##");
    append("## " + location);
    append("##");
    append("##############");
    append("");

    appendRequestChain(request);

    appendResponseChain(response);

    append("Path elements:");
    append("    RequestUri  = " + request.getRequestURI());
    append("    ContextPath = " + request.getContextPath());
    append("    ServletPath = " + request.getServletPath());
    append("    PathInfo    = " + request.getPathInfo());
    append("    QueryString = " + request.getQueryString());
    String x = request.getContextPath() + request.getServletPath()
            + StringUtils.defaultString(request.getPathInfo());
    if (!request.getRequestURI().equals(x)) {
        append("ERROR RequestURI is [" + request.getRequestURI() + "] according to spec it should be [" + x
                + "]");
    } else {
        append("    Request path elements are in sync (requestURI = contextPath + servletPath + pathInfo) (SRV 3.4)");
    }
    append("");

    append("Forward attributes:");
    printAttribute(request, "javax.servlet.forward.request_uri");
    printAttribute(request, "javax.servlet.forward.context_path");
    printAttribute(request, "javax.servlet.forward.servlet_path");
    printAttribute(request, "javax.servlet.forward.path_info");
    printAttribute(request, "javax.servlet.forward.query_string");
    append("");

    append("Include attributes:");
    printAttribute(request, "javax.servlet.include.request_uri");
    printAttribute(request, "javax.servlet.include.context_path");
    printAttribute(request, "javax.servlet.include.servlet_path");
    printAttribute(request, "javax.servlet.include.path_info");
    printAttribute(request, "javax.servlet.include.query_string");
    append("");
}

From source file:com.digitalmisfits.support.compat.jasig.cas.web.flow.CasDefaultFlowUrlHandler.java

@Override
public String createFlowDefinitionUrl(final String flowId, final AttributeMap input,
        final HttpServletRequest request) {
    return request.getRequestURI() + (request.getQueryString() != null ? "?" + request.getQueryString() : "");
}

From source file:web.logging.ExceptionLoggerAdvice.java

private String extractUrlFromRequest(HttpServletRequest request) {
    String url = request.getRequestURI();
    String query = request.getQueryString();
    if (StringUtils.hasText(query)) {
        url += "?" + request.getQueryString();
    }/*ww  w .j ava 2 s  . c  om*/
    return url;
}

From source file:nl.knmi.adaguc.services.oauth2.OAuth2Handler.java

/**
 * Step 1: Starts Oauth2 authentication request. It retrieves a one time
 * usable code which can be used to retrieve an access token or id token
 * /*from  ww  w .  j  av a  2s  . c o m*/
 * @param httpRequest
 * @return
 * @throws OAuthSystemException
 * @throws IOException
 * @throws ElementNotFoundException
 */
static void getCode(HttpServletRequest httpRequest, HttpServletResponse response)
        throws OAuthSystemException, IOException, ElementNotFoundException {

    Debug.println("getQueryString:" + httpRequest.getQueryString());

    String returnURL = "";
    try {
        returnURL = HTTPTools.getHTTPParam(httpRequest, "returnurl");
    } catch (Exception e1) {
        Debug.println("Note: No redir URL given");
    }

    cleanStateObjects();

    String stateID = UUID.randomUUID().toString();

    Debug.println("Putting info in stateID [" + stateID + "]");
    oauthStatesMapper.put(stateID, new StateObject(returnURL));

    String provider = null;
    try {
        provider = HTTPTools.getHTTPParam(httpRequest, "provider");
    } catch (Exception e) {
    }
    Debug.println("  OAuth2 Step 1 getCode: Provider is " + provider);

    OAuthConfigurator.Oauth2Settings settings = OAuthConfigurator.getOAuthSettings(provider);
    if (settings == null) {
        Debug.errprintln("  OAuth2 Step 1 getCode: No Oauth settings set");
        return;
    }
    Debug.println("  OAuth2 Step 1 getCode: Using " + settings.id);

    JSONObject state = new JSONObject();
    try {
        state.put("provider", provider);
        state.put("state_id", stateID);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    OAuthClientRequest oauth2ClientRequest = OAuthClientRequest.authorizationLocation(settings.OAuthAuthLoc)
            .setClientId(settings.OAuthClientId)
            .setRedirectURI(MainServicesConfigurator.getServerExternalURL() + oAuthCallbackURL)
            .setScope(settings.OAuthClientScope).setResponseType("code").setState(state.toString())
            .buildQueryMessage();

    Debug.println("  OAuth2 Step 1 getCode: locationuri = " + oauth2ClientRequest.getLocationUri());
    response.sendRedirect(oauth2ClientRequest.getLocationUri());
}

From source file:org.craftercms.engine.http.impl.AlfrescoHttpProxy.java

@Override
protected String createTargetQueryString(HttpServletRequest request) {
    String queryString = request.getQueryString();
    String alfTicket = getCurrentTicket(request);

    if (queryString == null) {
        queryString = "";
    }//ww w.j  a  va  2s  .  com

    if (alfTicket != null) {
        MultiValueMap<String, String> queryParams = HttpUtils.getParamsFromQueryString(queryString);
        queryParams.set("alf_ticket", alfTicket);

        try {
            queryString = HttpUtils.getQueryStringFromParams(queryParams, "UTF-8");
            //queryString = URLDecoder.decode(queryString, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            logger.error("Unable to encode params " + queryParams + " into a query string", e);
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("'" + alfrescoTicketCookieName + "' cookie not specified. Proxy request will be "
                    + "generated without it");
        }

        if (StringUtils.isNotEmpty(queryString)) {
            queryString = "?" + queryString;
        }
    }

    return queryString;
}

From source file:cec.easyshop.storefront.controllers.integration.BaseIntegrationController.java

protected void initializeSiteFromRequest(final HttpServletRequest httpRequest) {

    final String queryString = httpRequest.getQueryString();
    final String currentRequestURL = httpRequest.getRequestURL().toString();
    final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/")
            + (StringUtils.isBlank(queryString) ? "" : "?" + queryString);

    try {/*  w w w . j av a  2 s  . c om*/

        final URL currentURL = new URL(absoluteURL);
        final CMSSiteModel cmsSiteModel = cmsSiteService.getSiteForURL(currentURL);
        if (cmsSiteModel != null) {
            baseSiteService.setCurrentBaseSite(cmsSiteModel, true);
        }
    } catch (final MalformedURLException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Cannot find CMSSite associated with current URL ( " + absoluteURL
                    + " - check whether this is correct URL) !");
        }
    } catch (final CMSItemNotFoundException e) {
        LOG.warn("Cannot find CMSSite associated with current URL (" + absoluteURL + ")!");
        if (LOG.isDebugEnabled()) {
            LOG.debug(e);
        }
    }
}

From source file:com.hp.autonomy.frontend.find.core.authentication.LoginController.java

@RequestMapping(value = FindController.DEFAULT_LOGIN_PAGE)
@ResponseBody// w  w  w  . ja v  a2 s .  c  o  m
public void login(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
    String queryString = request.getQueryString();
    final Authentication<?> authentication = this.configService.getConfig().getAuthentication();

    if (LoginTypes.DEFAULT.equalsIgnoreCase(authentication.getMethod())) {
        final String defaultUsername = authentication.getDefaultLogin().getUsername();

        if (queryString != null) {
            queryString = "defaultLogin=" + defaultUsername + '&' + queryString;
        } else {
            queryString = "defaultLogin=" + defaultUsername;
        }
    }

    String redirectUrl = request.getContextPath() + FindController.LOGIN_PATH;

    if (queryString != null) {
        redirectUrl += '?' + queryString;
    }

    response.sendRedirect(redirectUrl);
}

From source file:com.lynn.controller.HttpAction.java

@RequestMapping("/header1.do")
@ResponseBody/* www  .  j a v  a 2 s  . c om*/
public String header1(HttpServletRequest request, HttpServletResponse response) {
    Enumeration e = request.getHeaderNames();
    String query = request.getQueryString();//??get??
    String etag = request.getHeader("etag");
    String if_none_match = request.getHeader("If-None-Match");
    String host = request.getHeader("host");
    String accept = request.getHeader("accept");
    String referer = request.getHeader("referer");
    String host1 = response.getHeader("host");
    String etag1 = response.getHeader("etag");
    String date1 = response.getHeader("date");
    String server1 = response.getHeader("server");
    return query;
}

From source file:com.groupon.odo.controllers.ConfigurationInterceptor.java

/**
 * This will check to see if certain configuration values exist from the ConfigurationService
 * If not then it redirects to the configuration screen
 *///from   ww w . j  av  a 2  s.  c om
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {

    String queryString = request.getQueryString() == null ? "" : request.getQueryString();

    if (ConfigurationService.getInstance().isValid() || request.getServletPath().startsWith("/configuration")
            || request.getServletPath().startsWith("/resources")
            || queryString.contains("requestFromConfiguration=true")) {
        return true;
    } else {
        response.sendRedirect("configuration");
        return false;
    }
}