Example usage for javax.servlet RequestDispatcher FORWARD_QUERY_STRING

List of usage examples for javax.servlet RequestDispatcher FORWARD_QUERY_STRING

Introduction

In this page you can find the example usage for javax.servlet RequestDispatcher FORWARD_QUERY_STRING.

Prototype

String FORWARD_QUERY_STRING

To view the source code for javax.servlet RequestDispatcher FORWARD_QUERY_STRING.

Click Source Link

Document

The name of the request attribute under which the original query string is made available to the target of a #forward(ServletRequest,ServletResponse) forward

Usage

From source file:cn.edu.zjnu.acm.judge.config.JudgeHandlerInterceptor.java

@ModelAttribute
public void addAttributes(HttpServletRequest request, @RequestParam(value = "url", required = false) String url,
        Authentication authentication) {
    if (Boolean.TRUE.equals(request.getAttribute(APPLIED_ONCE_KEY))) {
        return;/* www.j  a va 2  s. c o  m*/
    }
    request.setAttribute(APPLIED_ONCE_KEY, true);

    if (!StringUtils.isEmptyOrWhitespace(url)) {
        request.setAttribute(BACK_URL_ATTRIBUTE_NAME, url);
    } else {
        String uri = getString(RequestDispatcher.FORWARD_SERVLET_PATH, HttpServletRequest::getServletPath,
                request);
        String query = getString(RequestDispatcher.FORWARD_QUERY_STRING, HttpServletRequest::getQueryString,
                request);
        if (query != null) {
            uri = uri + '?' + query;
        }
        request.setAttribute(BACK_URL_ATTRIBUTE_NAME, uri);
    }
    Optional.ofNullable(authentication).map(Authentication::getName).map(mailMapper::getMailInfo)
            .ifPresent(mailInfo -> request.setAttribute("mailInfo", mailInfo));
}

From source file:org.ireland.jnetty.webapp.RequestDispatcherImpl.java

private void doForward(HttpServletRequest request, HttpServletResponse response, HttpInvocation invocation)
        throws ServletException, IOException {

    // Reset any output that has been buffered, but keep headers/cookies
    response.resetBuffer(); // Servlet-3_1-PFD 9.4

    //Wrap the request
    ForwardRequest wrequest = new ForwardRequest(request, response, invocation);

    // If we have already been forwarded previously, then keep using the established
    // original value. Otherwise, this is the first forward and we need to establish the values.
    // Note: the established value on the original request for pathInfo and
    // for queryString is allowed to be null, but cannot be null for the other values.
    if (request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI) == null) {
        // ??,//  w  w w. ja v a 2s. co  m
        wrequest.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, request.getRequestURI());

        wrequest.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, request.getContextPath());
        wrequest.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, request.getServletPath());
        wrequest.setAttribute(RequestDispatcher.FORWARD_PATH_INFO, request.getPathInfo());
        wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING, request.getQueryString());
    }

    boolean isValid = false;

    try {

        invocation.getFilterChainInvocation().service(wrequest, response);

        isValid = true;
    } finally {
        if (request.getAsyncContext() != null) {
            // An async request was started during the forward, don't close the
            // response as it may be written to during the async handling
            return;
        }

        // server/106r, ioc/0310
        if (isValid) {
            finishResponse(response);
        }
    }
}