Example usage for com.google.gwt.http.client Response SC_MOVED_PERMANENTLY

List of usage examples for com.google.gwt.http.client Response SC_MOVED_PERMANENTLY

Introduction

In this page you can find the example usage for com.google.gwt.http.client Response SC_MOVED_PERMANENTLY.

Prototype

int SC_MOVED_PERMANENTLY

To view the source code for com.google.gwt.http.client Response SC_MOVED_PERMANENTLY.

Click Source Link

Usage

From source file:org.broadleafcommerce.cms.web.URLHandlerFilter.java

License:Apache License

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

    String contextPath = request.getContextPath();
    String requestURIWithoutContext;
    if (request.getContextPath() != null) {
        requestURIWithoutContext = request.getRequestURI().substring(request.getContextPath().length());
    } else {//  w w w  .j  a v a2s  .  c om
        requestURIWithoutContext = request.getRequestURI();
    }
    URLHandler handler = urlHandlerService.findURLHandlerByURI(requestURIWithoutContext);

    if (handler != null) {
        if (URLRedirectType.FORWARD == handler.getUrlRedirectType()) {
            request.getRequestDispatcher(handler.getNewURL()).forward(request, response);
        } else if (URLRedirectType.REDIRECT_PERM == handler.getUrlRedirectType()) {
            String url = UrlUtil.fixRedirectUrl(contextPath, handler.getNewURL());
            response.setStatus(Response.SC_MOVED_PERMANENTLY);
            response.setHeader("Location", url);
            response.setHeader("Connection", "close");
        } else if (URLRedirectType.REDIRECT_TEMP == handler.getUrlRedirectType()) {
            String url = UrlUtil.fixRedirectUrl(contextPath, handler.getNewURL());
            response.sendRedirect(url);
        }
    } else {
        filterChain.doFilter(request, response);
    }
}