Example usage for javax.servlet.http HttpServletResponse setStatus

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

Introduction

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

Prototype

@Deprecated
public void setStatus(int sc, String sm);

Source Link

Usage

From source file:com.logsniffer.web.controller.exception.RestErrorHandler.java

private static ErrorResponse processExceptionResponse(final Throwable ex, final HttpServletResponse response,
        final int status) throws IOException {
    LOGGER.info("Catched exception", ex);
    final ErrorResponse er = new ErrorResponse();
    er.setException(ex);//  w ww  .java 2s  . c o m
    response.setStatus(status, er.getExceptionMessage());
    return er;
}

From source file:org.openmrs.module.webservices.rest.web.RestUtil.java

/**
 * Sets the HTTP status on the response according to the exception
 * //from   w w w .j  av a2 s .c o m
 * @param ex
 * @param response
 */
public static void setResponseStatus(Throwable ex, HttpServletResponse response) {
    ResponseStatus ann = ex.getClass().getAnnotation(ResponseStatus.class);
    if (ann != null) {
        if (StringUtils.isNotBlank(ann.reason())) {
            response.setStatus(ann.value().value(), ann.reason());
        } else {
            response.setStatus(ann.value().value());
        }
    } else {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}