Example usage for javax.servlet.http HttpServletResponse getStatus

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

Introduction

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

Prototype

public int getStatus();

Source Link

Document

Gets the current status code of this response.

Usage

From source file:it.greenvulcano.gvesb.adapter.http.utils.DumpUtils.java

public static void dump(HttpServletResponse response, ByteArrayOutputStream body, StringBuffer log) {

    log.append("-- DUMP HttpServletResponse START").append("\n");
    log.append("Status: ").append(response.getStatus()).append("\n");
    log.append("---- Headers START\n");

    response.getHeaderNames().stream()/*from w ww.j  a va2s.  c  o m*/
            .map(headerName -> "[" + headerName + "]=[" + response.getHeaders(headerName) + "]")
            .forEach(h -> log.append(h));

    log.append("---- Headers END\n");

    log.append("---- Body START\n");
    log.append(body.toString()).append("\n");
    log.append("---- Body END\n");

    log.append("-- DUMP HttpServletResponse END \n");
}

From source file:org.openehealth.ipf.commons.ihe.ws.cxf.payload.WsPayloadLoggerBase.java

private static String getOutboundMetadataPayload(Message message) {
    StringBuilder sb = new StringBuilder();

    Object endpointAddress = message.get(Message.ENDPOINT_ADDRESS);
    if (endpointAddress != null) {
        sb.append("Target endpoint: ").append(endpointAddress).append('\n');
    } else {/*from  ww  w  . j  av  a2s. co  m*/
        HttpServletResponse response = (HttpServletResponse) message.get(AbstractHTTPDestination.HTTP_RESPONSE);
        sb.append("HTTP response code: ").append((response != null) ? response.getStatus() : "unknown")
                .append('\n');
    }

    return sb.toString();
}

From source file:nl.dtls.fairdatapoint.api.controller.utils.LoggerUtils.java

/**
 * Log the request./*from   w  ww . java  2 s.  c om*/
 * 
 * Log message pattern [Time\t IP\t requestMethod\t requestedURL]
 * @param logger    Class logger
 * @param request   Client request
 * @param response  Server response
 */
public static void logRequest(Logger logger, HttpServletRequest request, HttpServletResponse response) {
    ThreadContext.put("requestMethod", request.getMethod());
    ThreadContext.put("requestURI", request.getRequestURI());
    ThreadContext.put("requestProtocol", request.getProtocol());
    ThreadContext.put("responseStatus", String.valueOf(response.getStatus()));
    String contentLength = response.getHeader(HttpHeaders.CONTENT_LENGTH);
    ThreadContext.put("contentSize", contentLength);
    logger.log(Level.getLevel("API-REQUEST"), "");
}

From source file:com.zimbra.cs.dav.service.DavServlet.java

public static StringBuilder addResponseHeaderLoggingInfo(HttpServletResponse resp, StringBuilder sb) {
    if (!ZimbraLog.dav.isDebugEnabled()) {
        return sb;
    }/*  ww  w.  j av a  2  s .  c om*/
    sb.append("DAV RESPONSE:\n");
    String statusLine = DavResponse.sStatusTextMap.get(resp.getStatus());
    if (statusLine != null) {
        sb.append(statusLine);
    } else {
        sb.append("HTTP/1.1 ").append(resp.getStatus());
    }
    Collection<String> hdrNames = resp.getHeaderNames();
    if (hdrNames != null && !hdrNames.isEmpty()) {
        for (String hdrName : hdrNames) {
            if (hdrName.contains("Auth") || (hdrName.contains(HttpHeaders.COOKIE))) {
                sb.append("\n").append(hdrName).append(": *** REPLACED ***");
                continue;
            }
            Collection<String> vals = resp.getHeaders(hdrName);
            for (String val : vals) {
                sb.append("\n").append(hdrName).append(": ").append(val);
            }
        }
    }
    sb.append("\n\n");
    return sb;
}

From source file:com.orange.clara.pivotaltrackermirror.controllers.CustomErrorController.java

@RequestMapping(value = PATH)
ErrorJson error(HttpServletRequest request, HttpServletResponse response) {
    return new ErrorJson(response.getStatus(), getErrorAttributes(request, debug));
}

From source file:org.zalando.zmon.actuator.ZmonMetricsFilter.java

private int getStatus(final HttpServletResponse response) {
    try {//from   w  ww  .java 2s  .  c  o  m
        return response.getStatus();
    } catch (Exception ex) {
        return UNDEFINED_HTTP_STATUS;
    }
}

From source file:com.intel.podm.rest.ServletCommunicationCoordinator.java

private boolean isSuccessfulGetResponse(HttpServletRequest servletRequest,
        HttpServletResponse servletResponse) {
    return isGetRequest(servletRequest) && familyOf(servletResponse.getStatus()) == SUCCESSFUL;
}

From source file:io.fabric8.che.starter.error.ErrorController.java

@RequestMapping(PATH)
public Error error(HttpServletRequest request, HttpServletResponse response) {
    // Appropriate HTTP response code (e.g. 404) is set automatically
    return new Error(response.getStatus(), getErrorAttributes(request, includeStackTrace));
}

From source file:org.smigo.config.RestExceptionResolver.java

private ModelAndView getModelAndView(HttpServletResponse response, HttpStatus httpStatus, Object[] model) {
    if (response.getStatus() == 200) {
        response.setStatus(httpStatus.value());
    }//ww w.  j  a va 2 s. c om
    ModelAndView jsonView = new ModelAndView(view);
    jsonView.addObject(model);
    return jsonView;
}

From source file:io.onedecision.engine.decisions.impl.LocationHeaderInterceptor.java

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) throws Exception {
    System.out.println("---Request Completed---");
    if (response.getStatus() == HttpStatus.CREATED.value()) {
        response.setHeader("Location", String.format("%1$s", request.getRequestURL()));
    }//www .  j ava 2 s .c  o  m
}