List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:com.microsoft.applicationinsights.web.utils.TestServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(HttpStatus.SC_OK); }
From source file:com.microsoft.applicationinsights.web.utils.TestServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(HttpStatus.SC_OK); }
From source file:cf.spring.HttpBasicAuthenticator.java
private void setUnathorizedResponse(HttpServletResponse response) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.addHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\""); }
From source file:com.github.wnameless.spring.bulkapi.BulkApiExceptionHandlerAdvice.java
/** * Sets the proper HTTP status code and returns the error message. * /*from w w w . j a v a 2 s. co m*/ * @param servRes * a {@link HttpServletResponse} * @param exception * a {@link BulkApiException} * @return an error message */ @ExceptionHandler(BulkApiException.class) @ResponseBody String handleError(HttpServletResponse servRes, BulkApiException exception) { servRes.setStatus(exception.getStatus().value()); return exception.getError(); }
From source file:cz.sohlich.workstack.api.SecurityResource.java
@RequestMapping(value = "/login") public void login(HttpServletResponse response) { log.info("Redirected to login via REST"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); }
From source file:net.sf.j2ep.responsehandlers.HeadResponseHandler.java
/** * Will only set the headers and status code, no response is sent. * // w ww .ja v a 2 s . c o m * @see net.sf.j2ep.model.ResponseHandler#process(javax.servlet.http.HttpServletResponse) */ public void process(HttpServletResponse response) { setHeaders(response); response.setStatus(getStatusCode()); }
From source file:net.jadler.stubbing.server.jetty.StubHandler.java
private void setStatus(final int status, final HttpServletResponse response) { response.setStatus(status); }
From source file:com.boundlessgeo.geoserver.api.exceptions.AppExceptionHandler.java
@ExceptionHandler(Exception.class) public @ResponseBody JSONObj error(Exception e, HttpServletResponse response) { HttpStatus status = status(e);// w w w. j a v a2 s .c o m response.setStatus(status.value()); // log at warning if 500, else debug LOG.log(status == HttpStatus.INTERNAL_SERVER_ERROR ? Level.WARNING : Level.FINE, e.getMessage(), e); return IO.error(new JSONObj(), e); }
From source file:cz.muni.fi.dndtroopsweb.controllers.BasicController.java
/** * just for testing purposes/*from w w w . ja va 2 s . c o m*/ * @param request * @param response * @return */ @RequestMapping(value = "/logout", method = RequestMethod.GET) public String logoutPage(HttpServletRequest request, HttpServletResponse response) { request.setAttribute("authenticatedUser", null); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return "home"; }
From source file:org.duracloud.duradmin.util.SpaceUtil.java
public static void streamToResponse(InputStream is, HttpServletResponse response, String mimetype, String contentLength) throws ContentStoreException, IOException { OutputStream outStream = response.getOutputStream(); try {// www. ja v a 2 s . c o m response.setContentType(mimetype); if (contentLength != null) { response.setContentLengthLong(Long.parseLong(contentLength)); } byte[] buf = new byte[1024]; int read = -1; while ((read = is.read(buf)) > 0) { outStream.write(buf, 0, read); } response.flushBuffer(); } catch (Exception ex) { if (ex.getCause() instanceof ContentStateException) { response.reset(); response.setStatus(HttpStatus.SC_CONFLICT); String message = "The requested content item is currently in long-term storage" + " with limited retrieval capability. Please contact " + "DuraCloud support (https://wiki.duraspace.org/x/6gPNAQ) " + "for assistance in retrieving this content item."; //It is necessary to pad the message in order to force Internet Explorer to //display the server sent text rather than display the browser default error message. //If the message is less than 512 bytes, the browser will ignore the message. //c.f. http://support.microsoft.com/kb/294807 message += StringUtils.repeat(" ", 512); outStream.write(message.getBytes()); } else { throw ex; } } finally { try { outStream.close(); } catch (Exception e) { log.warn("failed to close outputstream ( " + outStream + "): message=" + e.getMessage(), e); } } }