Example usage for javax.servlet.http HttpServletResponse sendError

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

Introduction

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

Prototype

public void sendError(int sc, String msg) throws IOException;

Source Link

Document

Sends an error response to the client using the specified status and clears the buffer.

Usage

From source file:com.netflix.scheduledactions.web.controllers.ValidationController.java

@ExceptionHandler(InvalidCronExpressionException.class)
void handleInvalidCronExpression(HttpServletResponse response, InvalidCronExpressionException e)
        throws IOException {
    response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage());
}

From source file:com.netflix.scheduledactions.web.controllers.ValidationController.java

@ExceptionHandler(InvalidISO8601IntervalException.class)
void handleInvalidISOExpression(HttpServletResponse response, InvalidISO8601IntervalException e)
        throws IOException {
    response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage());
}

From source file:de.otto.jsonhome.registry.controller.RegistryHtmlController.java

@ResponseStatus(value = NOT_FOUND)
@ExceptionHandler({ IllegalArgumentException.class })
public void handleNotFound(final IllegalArgumentException e, final HttpServletResponse response)
        throws IOException {
    response.sendError(404, e.getMessage());
}

From source file:cz.zcu.kiv.eegdatabase.webservices.rest.datafile.DataFileServiceController.java

/**
 * Exception handler for RestServiceException.class.
 * Writes exception message into HTTP response.
 *
 * @param ex       exception body/*from  w  w  w .j a va2s  . com*/
 * @param response HTTP response
 * @throws IOException error while writing into response
 */
@ExceptionHandler(RestServiceException.class)
public void handleException(RestServiceException ex, HttpServletResponse response) throws IOException {
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
    log.error(ex);
}

From source file:cz.zcu.kiv.eegdatabase.webservices.rest.datafile.DataFileServiceController.java

/**
 * Exception handler for RestNotFoundException.class.
 * Writes exception message into HTTP response.
 *
 * @param ex       exception body//w  ww .  j a v  a2 s  . co m
 * @param response HTTP response
 * @throws IOException error while writing into response
 */
@ExceptionHandler(RestNotFoundException.class)
public void handleException(RestNotFoundException ex, HttpServletResponse response) throws IOException {
    response.sendError(HttpServletResponse.SC_NOT_FOUND, ex.getMessage());
    log.error(ex);
}

From source file:cz.zcu.kiv.eegdatabase.webservices.rest.reservation.ReservationServiceController.java

/**
 * Exception handler for RestServiceException.class.
 * Writes exception message into HTTP response.
 *
 * @param ex       exception body/*from  w  w w  . j a v  a  2  s.  c o  m*/
 * @param response HTTP response
 * @throws IOException error while writing error into response
 */
@ExceptionHandler(RestServiceException.class)
public void handleRSException(RestServiceException ex, HttpServletResponse response) throws IOException {
    log.error(ex);
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
}

From source file:com.lennonjesus.auth.security.handler.AjaxAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    logger.debug("Authentication Failed");
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication failed");
}

From source file:com.autoupdater.server.controllers.AppController.java

/**
 * Sends error instead of displaying page.
 * /*from   www . j  a v  a2s .c o  m*/
 * @param response
 *            response instance
 * @param errorCode
 *            error code from HttpServletResponse
 * @param message
 *            message to display
 */
protected void sendError(HttpServletResponse response, int errorCode, String message) {
    try {
        response.sendError(errorCode, message);
    } catch (IOException e) {
        logger.error(e);
    }
}

From source file:com.tamnd.app.config.security.EntryPointAuthenticationHandler.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex)
        throws IOException, ServletException {
    if (ex instanceof BadCredentialsException) {
        response.sendError(HttpServletResponse.SC_EXPECTATION_FAILED, "User name or password is wrong!");
    }//w  ww. j  a va 2s  .co  m
}

From source file:com.graphhopper.http.GHBaseServlet.java

void returnError(HttpServletResponse res, String errorMessage) throws IOException {
    res.sendError(SC_BAD_REQUEST, errorMessage);
}