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:com.swdouglass.joid.server.OpenIdServlet.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doQuery(request.getQueryString(), request, response);
}

From source file:net.shopxx.plugin.tlpay.TlpayPlugin.java

@Override
public String getNotifyMessage(String sn, NotifyMethod notifyMethod, HttpServletRequest request) {
    if (SIGN_TYPE_CENT.equals(WebUtils.getParameter(request.getQueryString(), "UTF-8", "signType"))) {
        return "success";
    }// ww  w  .ja  va  2  s  . com
    return null;
}

From source file:com.ctc.storefront.filters.StorefrontFilter.java

@Override
public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws IOException, ServletException {
    final HttpSession session = request.getSession();
    final String queryString = request.getQueryString();

    if (isSessionNotInitialized(session, queryString)) {
        initDefaults(request);/*w  w w . j  a  v a 2s.c o  m*/

        markSessionInitialized(session);
    }

    // For secure requests ensure that the JSESSIONID cookie is visible to insecure requests
    if (isRequestSecure(request)) {
        fixSecureHttpJSessionIdCookie(request, response);
    }

    if (isGetMethod(request)) {
        if (StringUtils.isBlank(request.getHeader(AJAX_REQUEST_HEADER_NAME))
                && !isRequestPathExcluded(request)) {
            final String requestURL = request.getRequestURL().toString();
            session.setAttribute(ORIGINAL_REFERER,
                    StringUtils.isNotBlank(queryString) ? requestURL + "?" + queryString : requestURL);
        }

        getBrowseHistory().addBrowseHistoryEntry(new BrowseHistoryEntry(request.getRequestURI(), null));
    }

    filterChain.doFilter(request, response);
}

From source file:edu.cornell.mannlib.vitro.webapp.filters.RequestLoggerFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {
    try {//from   w w w.j a v a 2s. co m
        if (request instanceof HttpServletRequest) {
            HttpServletRequest theRequest = (HttpServletRequest) request;
            StringBuffer requestedLocation = new StringBuffer();
            requestedLocation.append(theRequest.getLocalName()).append(":");
            requestedLocation.append(theRequest.getLocalPort());
            requestedLocation.append(theRequest.getRequestURI());
            if (theRequest.getQueryString() != null) {
                requestedLocation.append("?").append(theRequest.getQueryString());
            }
            log.debug("Incoming request: " + requestedLocation.toString());
        }
    } catch (Exception e) {
        // This shouldn't really happen, but if it does, we'll be ready for it.
    } finally {
        filterChain.doFilter(request, response);
    }
}

From source file:com.ibm.watson.ta.retail.DemoServlet.java

/**
 * Create and POST a request to the Watson service
 *
 * @param req//  w w  w.  j  a  v  a  2s. com
 *            the Http Servlet request
 * @param resp
 *            the Http Servlet response
 * @throws ServletException
 *             the servlet exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {

    req.setCharacterEncoding("UTF-8");
    try {
        String queryStr = req.getQueryString();
        String url = baseURL + "/v1/dilemmas";
        if (queryStr != null) {
            url += "?" + queryStr;
        }
        URI uri = new URI(url).normalize();
        logger.info("posting to " + url);

        Request newReq = Request.Post(uri);
        newReq.addHeader("Accept", "application/json");
        InputStreamEntity entity = new InputStreamEntity(req.getInputStream());
        newReq.bodyString(EntityUtils.toString(entity, "UTF-8"), ContentType.APPLICATION_JSON);

        Executor executor = this.buildExecutor(uri);
        Response response = executor.execute(newReq);
        HttpResponse httpResponse = response.returnResponse();
        resp.setStatus(httpResponse.getStatusLine().getStatusCode());

        ServletOutputStream servletOutputStream = resp.getOutputStream();
        httpResponse.getEntity().writeTo(servletOutputStream);
        servletOutputStream.flush();
        servletOutputStream.close();

        logger.info("post done");
    } catch (Exception e) {
        // Log something and return an error message
        logger.log(Level.SEVERE, "got error: " + e.getMessage(), e);
        resp.setStatus(HttpStatus.SC_BAD_GATEWAY);
    }
}

From source file:dinamica.util.matcher.RegexRequestMatcher.java

/**
 * Performs the match of the request URL ({@code servletPath + pathInfo + queryString}
 * ) against the compiled pattern. If the query string is present, a question mark
 * will be prepended./*from   w w w .j av  a  2 s.  c o  m*/
 *
 * @param request the request to match
 * @return true if the pattern matches the URL, false otherwise.
 */
public boolean matches(HttpServletRequest request) {
    if (httpMethod != null && request.getMethod() != null && httpMethod != valueOf(request.getMethod())) {
        return false;
    }

    String url = request.getServletPath();
    String pathInfo = request.getPathInfo();
    String query = request.getQueryString();

    if (pathInfo != null || query != null) {
        StringBuilder sb = new StringBuilder(url);

        if (pathInfo != null) {
            sb.append(pathInfo);
        }

        if (query != null) {
            sb.append('?').append(query);
        }
        url = sb.toString();
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Checking match of request : '" + url + "'; against '" + pattern + "'");
    }

    return pattern.matcher(url).matches();
}

From source file:com.yahoo.dba.perf.myperf.springmvc.MyPerfBaseController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp)
        throws Exception {
    logger.info("receive url path: " + req.getContextPath() + "," + req.getRequestURI() + ", "
            + req.getServletPath() + ", parameters: " + req.getQueryString());

    AppUser user = retrieveAppUser(req);

    if (this.requireLogin && user == null)//check if user valid when require login
    {/*from  w w w .  ja  va 2 s  . c o  m*/
        if (this.nosessView != null)
            return new ModelAndView(new RedirectView(nosessView));
        return respondFailure("Session expired. Please relogin and try again.", req);
    } else if (this.requireLogin && !user.isVerified()) {
        //TODO use a message view
        return this.respondFailure(
                "New user request has not been verified by administrator yet. Please contact administrator by email "
                        + this.frameworkContext.getMyperfConfig().getAdminEmail() + ".",
                req);
    }

    return handleRequestImpl(req, resp);
}

From source file:Controladores.AutorizadorAcesso.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object controller)
        throws Exception {

    String uri = request.getRequestURI();

    if (uri.toUpperCase().contains("RESTRITO")) {
        if (request.getSession().getAttribute("logado") == null
                || (boolean) request.getSession().getAttribute("logado") == false) {

            if (request.getQueryString() != null) {
                uri += "?" + request.getQueryString();
            }//  w w w  .  j av a  2s .c  o m

            request.getSession().setAttribute("endereco", uri);

            RequestDispatcher dispacher = request.getRequestDispatcher("exibe-login");
            dispacher.forward(request, response);
            return false;
        }
    }
    return true;
}