Example usage for javax.servlet.http HttpServletResponse getClass

List of usage examples for javax.servlet.http HttpServletResponse getClass

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.energyos.espi.common.utils.StringToLongFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException {

    if (logger.isDebugEnabled()) {

        logger.debug("StringToLongFilter processing");

        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        logger.debug("Request is " + httpRequest.getClass());
        logger.debug("Request URL: " + httpRequest.getRequestURL());
        logger.debug("Request Method is '" + httpRequest.getMethod() + "'");
        logger.debug("Response is " + httpResponse.getClass());

    }//from  w  w w . ja  v a  2 s.  co m

    // TODO: Add Long to String conversion logic

    filterChain.doFilter(request, response);
}

From source file:com.sun.identity.provider.springsecurity.OpenSSOAuthenticationEntryPoint.java

public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;
        request = HttpUtil.unwrapOriginalHttpServletRequest(httpRequest);
        redirectToLoginUrl(httpRequest, httpResponse);
    } else {// w  w w.  j a  va  2s  .  co  m
        debug.error("Request: " + request.getClass() + " Response: " + response.getClass());
        throw new ServletException("Handles only HttpServletRequest/Response");
    }
}

From source file:grails.plugin.cache.web.filter.PageFragmentCachingFilter.java

/**
 * Assembles a response from a cached page include. These responses are never
 * gzipped The content length should not be set in the response, because it
 * is a fragment of a page. Don't write any headers at all.
 *///from  w  ww  .  java  2 s . co m
protected void writeResponse(final HttpServletResponse response, final PageInfo pageInfo) throws IOException {
    byte[] cachedPage = pageInfo.getUngzippedBody();
    String page = new String(cachedPage, response.getCharacterEncoding());

    String implementationVendor = response.getClass().getPackage().getImplementationVendor();
    if (implementationVendor != null && implementationVendor.equals("\"Evermind\"")) {
        response.getOutputStream().print(page);
    } else {
        response.getWriter().write(page);
    }
}

From source file:com.meltmedia.cadmium.servlets.ErrorPageFilter.java

/**
 * Called to render the error page, if possible.
 * /*  ww w . j  a v  a 2s.  c  o m*/
 * @param sc the status code of the error.
 * @param message the message for the error.
 * @param request the request that caused the error.
 * @param response the response that the error will be written to.
 * @throws IOException if there is a problem rendering the error page.
 */
@SuppressWarnings("deprecation")
protected void sendError(int sc, String message, HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    if (400 <= sc && sc < 600 && !response.isCommitted()) {
        String[] fileNames = new String[] { "/" + Integer.toString(sc) + ".html",
                "/" + Integer.toString(sc).subSequence(0, 2) + "x.html",
                "/" + Integer.toString(sc).subSequence(0, 1) + "xx.html" };

        InputStream errorPageIn = null;
        try {
            String path = request.getRequestURI();
            while (path != null && errorPageIn == null) {
                if (path.endsWith("/")) {
                    path = path.substring(0, path.length() - 1);
                }
                for (String fileName : fileNames) {
                    if ((errorPageIn = contentService.getResourceAsStream(path + fileName)) != null) {
                        log.trace("Found error page for path {} at {}", path, path + fileName);
                        break;
                    }
                }
                if (errorPageIn == null) {
                    if (path.length() > 0) {
                        path = path.substring(0, path.lastIndexOf("/"));
                    } else {
                        path = null;
                    }
                }
            }

            // get the default page.
            if (errorPageIn == null) {
                for (String fileName : fileNames) {
                    if ((errorPageIn = ErrorPageFilter.class.getResourceAsStream(fileName)) != null) {
                        log.trace("Found error page at {}", fileName);
                        break;
                    } else if ((errorPageIn = ErrorPageFilter.class
                            .getResourceAsStream("./" + fileName)) != null) {
                        log.trace("Found error page at {}", "./" + fileName);
                        break;
                    }
                }
            }

            if (errorPageIn == null) {
                log.trace("No error page found.");
                if (message == null)
                    response.sendError(sc);
                else
                    response.sendError(sc, message);
                return;
            }

            // set the status code.
            if (message != null)
                response.setStatus(sc, message);
            else
                response.setStatus(sc);

            // create a UTF-8 reader for the error page content.
            response.setContentType(MediaType.TEXT_HTML);
            log.trace("Sending error page content to response:{}", response.getClass().getName());
            IOUtils.copy(errorPageIn, response.getOutputStream());
            log.trace("Done sending error page. {}", sc);
        } finally {
            IOUtils.closeQuietly(errorPageIn);
            IOUtils.closeQuietly(response.getOutputStream());
        }
    } else {
        if (response.isCommitted())
            log.trace("Response is committed!");
        if (message == null)
            response.sendError(sc);
        else
            response.sendError(sc, message);
    }
}

From source file:it.classhidra.core.controller.bsController.java

public static i_action getActionInstance(String id_action, String id_call, HttpServletRequest request,
        HttpServletResponse response) throws bsControllerException, ServletException, UnavailableException {

    boolean cloned = (request.getParameter(CONST_ID_EXEC_TYPE) == null) ? false
            : request.getParameter(CONST_ID_EXEC_TYPE).equalsIgnoreCase(CONST_ID_EXEC_TYPE_CLONED);

    i_action action_instance = getAction_config().actionFactory(id_action, request.getSession(),
            request.getSession().getServletContext());

    i_bean bean_instance = getCurrentForm(id_action, request);

    if (bean_instance == null) {
        info_bean iBean = (info_bean) getAction_config().get_beans()
                .get(action_instance.get_infoaction().getName());
        if (action_instance instanceof i_bean && (action_instance.get_infoaction().getName().equals("")
                || (iBean != null && action_instance.get_infoaction().getType().equals(iBean.getType()))))
            bean_instance = (i_bean) action_instance;
        else// w  ww  . j ava  2  s .c  om
            bean_instance = getAction_config().beanFactory(action_instance.get_infoaction().getName(),
                    request.getSession(), request.getSession().getServletContext(), action_instance);
        if (bean_instance != null) {
            if (bean_instance.getCurrent_auth() == null
                    || action_instance.get_infoaction().getMemoryInSession().equalsIgnoreCase("true"))
                bean_instance.setCurrent_auth(bsController.checkAuth_init(request));
            bean_instance.reimposta();
        }

        //Modifica 20100521 WARNING
        if (cloned) {
            try {
                action_instance.onPreSet_bean();
                action_instance.set_bean((i_bean) bean_instance.clone());
                action_instance.onPostSet_bean();
            } catch (Exception e) {
                action_instance.onPreSet_bean();
                action_instance.set_bean(bean_instance);
                action_instance.onPostSet_bean();
            }
        } else {
            action_instance.onPreSet_bean();
            action_instance.set_bean(bean_instance);
            action_instance.onPostSet_bean();
        }
    } else {

        if (bean_instance.getCurrent_auth() == null
                || action_instance.get_infoaction().getMemoryInSession().equalsIgnoreCase("true"))
            bean_instance.setCurrent_auth(bsController.checkAuth_init(request));

        if (action_instance instanceof i_bean && (action_instance.get_infoaction().getName().equals("")
                || bean_instance.getClass().getName().equals(action_instance.getClass().getName()))) {
            if (cloned) {
                try {
                    action_instance = (i_action) util_cloner.clone(bean_instance);
                } catch (Exception e) {
                    action_instance = (i_action) bean_instance;
                }
            } else
                action_instance = (i_action) bean_instance;
        } else {
            if (cloned) {
                try {
                    action_instance.onPreSet_bean();
                    action_instance.set_bean((i_bean) util_cloner.clone(bean_instance));
                    action_instance.onPostSet_bean();
                } catch (Exception e) {
                    action_instance.onPreSet_bean();
                    action_instance.set_bean(bean_instance);
                    action_instance.onPostSet_bean();
                }
            } else {
                action_instance.onPreSet_bean();
                action_instance.set_bean(bean_instance);
                action_instance.onPostSet_bean();
            }
        }
    }

    action_instance.onPreInit(request, response);
    action_instance.init(request, response);
    action_instance.onPostInit(request, response);

    info_call iCall = null;

    Method iCallMethod = null;

    if (id_call != null) {
        try {
            iCall = (info_call) action_instance.get_infoaction().get_calls().get(id_call);
            if (iCall == null) {
                Object[] method_call = action_instance.getMethodAndCall(id_call);
                if (method_call != null) {
                    iCallMethod = (Method) method_call[0];
                    iCall = (info_call) method_call[1];
                    action_instance.get_infoaction().get_calls().put(iCall.getName(), iCall);
                }

                /*               
                               iCallMethod = action_instance.getMethodForCall(id_call);
                        
                        
                        
                               if(iCallMethod!=null){
                                  iCall = new info_call();
                                  iCall.setMethod(iCallMethod.getName());
                                  action_instance.get_infoaction().get_calls().put(iCall.getName(),iCall);
                               }
                */
            } else {
                try {
                    iCallMethod = util_reflect.getMethodName(action_instance, iCall.getMethod(),
                            new Class[] { request.getClass(), response.getClass() });
                } catch (Exception em) {
                }
            }
        } catch (Exception ex) {
            new bsControllerException(ex, iStub.log_ERROR);
        } catch (Throwable th) {
            new bsControllerException(th, iStub.log_ERROR);
        }
    }

    if (iCall != null && iCall.getNavigated().equalsIgnoreCase("false")) {
    } else
        setInfoNav_CurrentForm(action_instance, request);

    // ACTIONSEVICE
    redirects current_redirect = null;
    if (id_call == null) {
        if (action_instance.get_infoaction().getSyncro().equalsIgnoreCase("true")) {
            action_instance.onPreSyncroservice(request, response);
            current_redirect = action_instance.syncroservice(request, response);
            action_instance.onPostSyncroservice(current_redirect, request, response);
        } else {

            current_redirect = action_instance.actionservice(request, response);
            action_instance.onPostActionservice(current_redirect, request, response);
        }
    } else {
        try {
            if (iCallMethod != null) {
                action_instance.onPreActionCall(id_call, request, response);
                current_redirect = (redirects) util_reflect.getValue(action_instance, iCallMethod,
                        new Object[] { request, response });
                action_instance.onPostActionCall(current_redirect, id_call, request, response);
            }
        } catch (Exception ex) {
            new bsControllerException(ex, iStub.log_ERROR);
        } catch (Throwable th) {
            new bsControllerException(th, iStub.log_ERROR);
        }
    }
    // Mod 20130923 -- 
    //      if(current_redirect==null) return null;
    action_instance.onPreSetCurrent_redirect();
    action_instance.setCurrent_redirect(current_redirect);
    action_instance.onPostSetCurrent_redirect();

    if (iCall != null && iCall.getNavigated().equalsIgnoreCase("false")) {
        try {
            i_bean form = action_instance.get_bean();
            if (form.get_infoaction().getMemoryInSession().equalsIgnoreCase("true")) {
                HashMap fromSession = null;
                fromSession = (HashMap) request.getSession()
                        .getAttribute(bsConstants.CONST_BEAN_$ONLYINSSESSION);
                if (fromSession == null) {
                    fromSession = new HashMap();
                    request.getSession().setAttribute(bsConstants.CONST_BEAN_$ONLYINSSESSION, fromSession);
                }
                if (form != null)
                    form.onAddToSession();
                fromSession.put(form.get_infobean().getName(), form);
            }
        } catch (Exception e) {
        }

    } else
        setCurrentForm(action_instance, request);

    return action_instance;

}

From source file:org.zkoss.zk.grails.web.ZULUrlMappingsFilter.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*w  w  w .  j  a  v a 2  s.c om*/
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    UrlMappingsHolder holder = WebUtils.lookupUrlMappings(getServletContext());

    String uri = urlHelper.getPathWithinApplication(request);

    if (uri.startsWith("/zkau") || uri.startsWith("/zkcomet") || uri.startsWith("/dbconsole")
            || uri.startsWith("/ext") || uri.startsWith("~.")) {
        LOG.debug("Excluding: " + uri);
        processFilterChain(request, response, filterChain);
        return;
    }

    if (!"/".equals(uri) && noControllers() && noComposers() && noRegexMappings(holder)) {
        // not index request, no controllers, and no URL mappings for views, so it's not a Grails request
        LOG.debug(
                "not index request, no controllers, and no URL mappings for views, so it's not a Grails request");
        processFilterChain(request, response, filterChain);
        return;
    }

    if (isUriExcluded(holder, uri)) {
        LOG.debug("Excluded by pattern: " + uri);
        processFilterChain(request, response, filterChain);
        return;
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Executing URL mapping filter...");
        LOG.debug(holder);
    }

    if (areFileExtensionsEnabled()) {
        String format = WebUtils.getFormatFromURI(uri, mimeTypes);
        if (format != null) {
            MimeType[] configuredMimes = mimeTypes == null ? MimeType.getConfiguredMimeTypes() : mimeTypes;
            // only remove the file extension if it's one of the configured mimes in Config.groovy
            for (MimeType configuredMime : configuredMimes) {
                if (configuredMime.getExtension().equals(format)) {
                    request.setAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT, format);
                    uri = uri.substring(0, (uri.length() - format.length() - 1));
                    break;
                }
            }
        }
    }

    GrailsWebRequest webRequest = (GrailsWebRequest) request
            .getAttribute(GrailsApplicationAttributes.WEB_REQUEST);
    UrlMappingInfo[] urlInfos = holder.matchAll(uri);
    WrappedResponseHolder.setWrappedResponse(response);
    boolean dispatched = false;
    try {
        // GRAILS-3369: Save the original request parameters.
        Map backupParameters;
        try {
            backupParameters = new HashMap(webRequest.getParams());
        } catch (Exception e) {
            LOG.error("Error creating params object: " + e.getMessage(), e);
            backupParameters = Collections.EMPTY_MAP;
        }

        for (UrlMappingInfo info : urlInfos) {
            if (info != null) {
                // GRAILS-3369: The configure() will modify the
                // parameter map attached to the web request. So,
                // we need to clear it each time and restore the
                // original request parameters.
                webRequest.getParams().clear();
                webRequest.getParams().putAll(backupParameters);

                final String viewName;
                try {
                    info.configure(webRequest);
                    String action = info.getActionName() == null ? "" : info.getActionName();
                    viewName = info.getViewName();
                    if (viewName == null && info.getURI() == null) {
                        final String controllerName = info.getControllerName();
                        String pluginName = info.getPluginName();
                        String featureUri = WebUtils.SLASH + urlConverter.toUrlElement(controllerName)
                                + WebUtils.SLASH + urlConverter.toUrlElement(action);

                        Object featureId = null;
                        if (pluginName != null) {
                            Map featureIdMap = new HashMap();
                            featureIdMap.put("uri", featureUri);
                            featureIdMap.put("pluginName", pluginName);
                            featureId = featureIdMap;
                        } else {
                            featureId = featureUri;
                        }
                        GrailsClass controller = application
                                .getArtefactForFeature(ControllerArtefactHandler.TYPE, featureId);
                        if (controller == null) {
                            if (uri.endsWith(".zul")) {
                                RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
                                dispatcher.forward(request, response);
                                dispatched = true;
                                break;
                            }
                            String zul = composerMapping.resolveZul(controllerName);
                            if (zul != null) {
                                RequestDispatcher dispatcher = request.getRequestDispatcher(zul);
                                dispatcher.forward(request, response);
                                dispatched = true;
                                break;
                            }
                        } else {
                            webRequest.setAttribute(GrailsApplicationAttributes.CONTROLLER_NAME_ATTRIBUTE,
                                    controller.getLogicalPropertyName(), WebRequest.SCOPE_REQUEST);
                            webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS,
                                    controller, WebRequest.SCOPE_REQUEST);
                            // webRequest.setAttribute(GrailsApplicationAttributes. GRAILS_CONTROLLER_CLASS_AVAILABLE, Boolean.TRUE, WebRequest.SCOPE_REQUEST);
                        }
                    }
                } catch (Exception e) {
                    if (e instanceof MultipartException) {
                        reapplySitemesh(request);
                        throw ((MultipartException) e);
                    }
                    LOG.error("Error when matching URL mapping [" + info + "]:" + e.getMessage(), e);
                    continue;
                }

                dispatched = true;

                if (!WAR_DEPLOYED) {
                    checkDevelopmentReloadingState(request);
                }

                request = checkMultipart(request);

                if (viewName == null || (viewName.endsWith(GSP_SUFFIX) || viewName.endsWith(JSP_SUFFIX))) {
                    if (info.isParsingRequest()) {
                        webRequest.informParameterCreationListeners();
                    }
                    String forwardUrl = WebUtils.forwardRequestForUrlMappingInfo(request, response, info);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Matched URI [" + uri + "] to URL mapping [" + info + "], forwarding to ["
                                + forwardUrl + "] with response [" + response.getClass() + "]");
                    }
                } else if (viewName != null && viewName.endsWith(ZUL_SUFFIX)) {
                    RequestDispatcher dispatcher = request.getRequestDispatcher(viewName);
                    dispatcher.forward(request, response);
                } else {
                    if (viewName == null) {
                        dispatched = false;
                    } else if (!renderViewForUrlMappingInfo(request, response, info, viewName)) {
                        dispatched = false;
                    }
                }
                break;
            }
        } // for
    } finally {
        WrappedResponseHolder.setWrappedResponse(null);
    }

    if (!dispatched) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No match found, processing remaining filter chain.");
        }
        processFilterChain(request, response, filterChain);
    }
}

From source file:org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver.java

protected void forwardRequest(UrlMappingInfo info, HttpServletRequest request, HttpServletResponse response,
        ModelAndView mv, String uri) throws ServletException, IOException {
    info.configure(WebUtils.retrieveGrailsWebRequest());
    String forwardUrl = WebUtils.forwardRequestForUrlMappingInfo(request, response, info, mv.getModel());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Matched URI [" + uri + "] to URL mapping [" + info + "], forwarding to [" + forwardUrl
                + "] with response [" + response.getClass() + "]");
    }/*from w  ww .  j  a v a  2s. c om*/
}

From source file:org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//from  w  w  w .  j  a va  2 s  .c om
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    UrlMappingsHolder holder = WebUtils.lookupUrlMappings(getServletContext());

    String uri = urlHelper.getPathWithinApplication(request);
    if (!"/".equals(uri) && noControllers() && noRegexMappings(holder)) {
        // not index request, no controllers, and no URL mappings for views, so it's not a Grails request
        processFilterChain(request, response, filterChain);
        return;
    }

    if (isUriExcluded(holder, uri)) {
        processFilterChain(request, response, filterChain);
        return;
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Executing URL mapping filter...");
        LOG.debug(holder);
    }

    GrailsWebRequest webRequest = (GrailsWebRequest) request
            .getAttribute(GrailsApplicationAttributes.WEB_REQUEST);
    HttpServletRequest currentRequest = webRequest.getCurrentRequest();
    String version = findRequestedVersion(webRequest);

    UrlMappingInfo[] urlInfos = holder.matchAll(uri, currentRequest.getMethod(),
            version != null ? version : UrlMapping.ANY_VERSION);
    WrappedResponseHolder.setWrappedResponse(response);
    boolean dispatched = false;
    try {

        for (UrlMappingInfo info : urlInfos) {
            if (info != null) {
                Object redirectInfo = info.getRedirectInfo();
                if (redirectInfo != null) {
                    final Map redirectArgs;
                    if (redirectInfo instanceof Map) {
                        redirectArgs = (Map) redirectInfo;
                    } else {
                        redirectArgs = CollectionUtils.newMap("uri", redirectInfo);
                    }
                    GrailsParameterMap params = webRequest.getParams();
                    redirectArgs.put("params", params);
                    redirectDynamicMethod.invoke(this, "redirect", new Object[] { redirectArgs });
                    dispatched = true;

                    break;
                }
                // GRAILS-3369: The configure() will modify the
                // parameter map attached to the web request. So,
                // we need to clear it each time and restore the
                // original request parameters.
                webRequest.resetParams();

                final String viewName;
                try {
                    info.configure(webRequest);
                    viewName = info.getViewName();
                    if (viewName == null && info.getURI() == null) {
                        ControllerArtefactHandler.ControllerCacheKey featureId = getFeatureId(info);
                        GrailsClass controller = application
                                .getArtefactForFeature(ControllerArtefactHandler.TYPE, featureId);
                        if (controller == null) {
                            continue;
                        }

                        webRequest.setAttribute(GrailsApplicationAttributes.CONTROLLER_NAME_ATTRIBUTE,
                                controller.getLogicalPropertyName(), WebRequest.SCOPE_REQUEST);
                        webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS, controller,
                                WebRequest.SCOPE_REQUEST);
                        webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE,
                                Boolean.TRUE, WebRequest.SCOPE_REQUEST);
                    }
                } catch (Exception e) {
                    if (e instanceof MultipartException) {
                        reapplySitemesh(request);
                        throw ((MultipartException) e);
                    }
                    LOG.error("Error when matching URL mapping [" + info + "]:" + e.getMessage(), e);
                    continue;
                }

                dispatched = true;

                if (!WAR_DEPLOYED) {
                    checkDevelopmentReloadingState(request);
                }

                request = checkMultipart(request);

                if (viewName == null || viewName.endsWith(GSP_SUFFIX) || viewName.endsWith(JSP_SUFFIX)) {
                    if (info.isParsingRequest()) {
                        webRequest.informParameterCreationListeners();
                    }
                    String forwardUrl = WebUtils.forwardRequestForUrlMappingInfo(request, response, info);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Matched URI [" + uri + "] to URL mapping [" + info + "], forwarding to ["
                                + forwardUrl + "] with response [" + response.getClass() + "]");
                    }
                } else {
                    if (!renderViewForUrlMappingInfo(request, response, info, viewName)) {
                        dispatched = false;
                    }
                }
                break;
            }
        }
    } finally {
        WrappedResponseHolder.setWrappedResponse(null);
    }

    if (!dispatched) {
        Set<HttpMethod> allowedHttpMethods = allowHeaderForWrongHttpMethod ? allowedMethods(holder, uri)
                : Collections.EMPTY_SET;

        if (allowedHttpMethods.isEmpty()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("No match found, processing remaining filter chain.");
            }
            processFilterChain(request, response, filterChain);
        } else {
            response.addHeader(HttpHeaders.ALLOW, DefaultGroovyMethods.join(allowedHttpMethods, ","));
            response.sendError(HttpStatus.METHOD_NOT_ALLOWED.value());
        }
    }
}

From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java

protected void buildResponseInfo(StringBuilder sb, HttpServletRequest request, HttpServletResponse response) {
    sb.append("Response class=" + response.getClass().getName());
    sb.append(", ContentType=").append(response.getContentType());
    sb.append(", Committed=").append(response.isCommitted());
    String exp = response.toString().trim();
    if (exp != null) {
        exp = replaceString(exp, "\r\n", "\n");
        exp = replaceString(exp, "\n", " ");
        final int limitLength = 120;
        if (exp.length() >= limitLength) {
            // it is possible that Response toString() show all HTML strings
            // so cut it to suppress too big logging here
            exp = exp.substring(0, limitLength) + "...";
        }//from ww w  .  j a  va2 s  .co  m
        sb.append(LF).append(IND);
        sb.append(", toString()=").append(exp);
        // e.g. Jetty
        // HTTP/1.1 200  Expires: Thu, 01-Jan-1970 00:00:00 GMT Set-Cookie: ...
    }
}

From source file:org.grails.web.errors.GrailsExceptionResolver.java

protected void forwardRequest(UrlMappingInfo info, HttpServletRequest request, HttpServletResponse response,
        ModelAndView mv, String uri) throws ServletException, IOException {
    info.configure(WebUtils.retrieveGrailsWebRequest());
    String forwardUrl = UrlMappingUtils.forwardRequestForUrlMappingInfo(request, response, info, mv.getModel());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Matched URI [" + uri + "] to URL mapping [" + info + "], forwarding to [" + forwardUrl
                + "] with response [" + response.getClass() + "]");
    }//from  w  w  w .  j  ava 2 s  .  c o m
}