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.toptal.conf.ConstraintViolationExceptionHandler.java

/**
 * Handles ConstraintViolationException.
 * @param exception Exception./*from ww  w  .  ja  v a 2 s  .  c om*/
 * @param resp Http response.
 * @throws IOException If smth goes wrong.
 * @checkstyle IndentationCheck (10 lines)
 */
@ExceptionHandler(ConstraintViolationException.class)
public void handle(final ConstraintViolationException exception, final HttpServletResponse resp)
        throws IOException {
    resp.sendError(HttpServletResponse.SC_BAD_REQUEST, exception.getMessage());
}

From source file:cn.featherfly.web.spring.servlet.view.NotFoundView.java

/**
 * {@inheritDoc}//from w  w  w  .  java  2 s.c  om
 */
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    response.sendError(HttpServletResponse.SC_NOT_FOUND, message);
}

From source file:web.logging.ExceptionLoggerAdvice.java

protected void sendStatus(HttpServletResponse response, HttpStatus status) throws IOException {
    response.sendError(status.value(), status.getReasonPhrase());
}

From source file:com.mycompany.springrest.token.RestAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException {

    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}

From source file:com.tamnd2.basicwebapp.security.EntryPointUnauthorizeHandler.java

@Override
public void commence(HttpServletRequest hsr, HttpServletResponse hsr1, AuthenticationException ae)
        throws IOException, ServletException {
    hsr1.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied");
}

From source file:com.headstartech.iam.web.controllers.ExceptionMapper.java

@ExceptionHandler(IAMException.class)
public void handleBadRequest(final HttpServletResponse response, final IAMException e) throws IOException {
    response.sendError(e.getErrorCode(), e.getLocalizedMessage());
}

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

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex)
        throws IOException, ServletException {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied");
}

From source file:com.company.project.web.controller.service.HttpAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage());
}

From source file:org.opens.urlmanager.rest.controller.GenericRestController.java

@ExceptionHandler(GenericRestException.class)
public void handleRestException(GenericRestException e, HttpServletRequest request,
        HttpServletResponse response) throws IOException {
    response.sendError(e.getCode(), e.getMessage());
}

From source file:de.otto.mongodb.profiler.web.AbstractController.java

@ExceptionHandler(ResourceNotFoundException.class)
public void onResourceNotFound(HttpServletResponse response) throws IOException {

    response.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource not found!");
}