List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc, String msg) throws IOException;
Sends an error response to the client using the specified status and clears the buffer.
From source file:com.alliander.osgp.shared.security.UnauthorizedEntryPoint.java
@Override public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized: Authentication token was either missing or invalid."); }
From source file:de.otto.jsonhome.controller.HtmlController.java
@ResponseStatus(value = NOT_FOUND) @ExceptionHandler({ IllegalArgumentException.class }) public void handleNotFound(final HttpServletResponse response) throws IOException { response.sendError(404, "Unknown link-relation type."); }
From source file:org.cbioportal.session_service.web.SessionServiceController.java
@ExceptionHandler public void handleSessionQueryInvalid(SessionQueryInvalidException e, HttpServletResponse response) throws IOException { response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); }
From source file:org.shredzone.commons.captcha.CaptchaServlet.java
@Override protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { if (!request.getMethod().equals("GET")) { response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, request.getMethod() + " is not accepted"); }//from w ww. j ava 2 s. c o m // Prepare header response.setDateHeader("Date", System.currentTimeMillis()); response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/png"); // Write captcha image CaptchaService cs = getWebApplicationContext().getBean("captchaService", CaptchaService.class); BufferedImage challenge = cs.createCaptcha(request.getSession()); ImageIO.write(challenge, "png", response.getOutputStream()); }
From source file:uk.ac.ebi.eva.server.ws.ga4gh.GA4GHVariantWSServer.java
@ExceptionHandler(IllegalArgumentException.class) public void handleException(IllegalArgumentException e, HttpServletResponse response) throws IOException { response.sendError(HttpStatus.PAYLOAD_TOO_LARGE.value(), e.getMessage()); }
From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.auth.RestAuthenticationEntryPoint.java
public final void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); }
From source file:org.trustedanalytics.h2oscoringengine.rest.H2oScoringEngineController.java
@ExceptionHandler(IllegalArgumentException.class) void handleIllegalArgumentException(IllegalArgumentException e, HttpServletResponse response) throws IOException { LOGGER.error("Invalid input data size:", e); response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); }
From source file:org.openwms.client.security.UnauthorizedEntryPoint.java
/** * {@inheritDoc}// ww w. j av a 2 s. c o m * * On {@link AuthenticationException}s we always commence with an * {@value HttpServletResponse#SC_UNAUTHORIZED} code. * * @see org.springframework.security.web.AuthenticationEntryPoint#commence(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, * org.springframework.security.core.AuthenticationException) */ @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized: Authentication token was either missing or invalid."); }
From source file:de.otto.jsonhome.controller.DocController.java
/** * Exception handler used to translate IOExceptions into HTTP 404 NOT FOUND. * * @param response the response object.//from w w w . ja va 2s . com * @throws IOException if sending the error fails for some reason. */ @ResponseStatus(value = NOT_FOUND) @ExceptionHandler(IOException.class) public void handleNotFound(final HttpServletResponse response) throws IOException { response.sendError(NOT_FOUND.value(), "File not found"); }
From source file:com.smartgwt.extensions.fileuploader.server.DownloadServlet.java
private void reportError(HttpServletResponse response) { try {//from ww w .j av a2s . com response.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not allowed to view that file"); } catch (IOException e) { } }