List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:com.graphhopper.http.GHBaseServlet.java
public void writeResponse(HttpServletResponse res, String str) { try {/* www . java 2s. c o m*/ res.setStatus(SC_OK); res.getWriter().append(str); } catch (IOException ex) { logger.error("Cannot write message:" + str, ex); } }
From source file:com.lennonjesus.auth.security.handler.AjaxAuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { logger.debug("Authentication Successful"); response.setStatus(HttpServletResponse.SC_OK); }
From source file:net.gplatform.sudoor.server.security.model.ResponseCodeHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { response.setStatus(responseCode); clearAuthenticationAttributes(request); }
From source file:org.fishwife.jrugged.spring.StatusController.java
private void setResponseCode(Status currentStatus, HttpServletResponse resp) { if (responseCodeMap.containsKey(currentStatus)) { resp.setStatus(responseCodeMap.get(currentStatus)); }/*from w w w . j a v a 2 s .c o m*/ }
From source file:org.osiam.addons.selfadministration.exception.OsiamExceptionHandler.java
@ExceptionHandler(OsiamRequestException.class) protected ModelAndView handleException(OsiamRequestException ex, HttpServletResponse response) { LOGGER.log(Level.WARNING, AN_EXCEPTION_OCCURED, ex); response.setStatus(ex.getHttpStatusCode()); modelAndView.addObject(KEY, "registration.form.error"); setLoggingInformation(ex);/*from ww w . j a v a 2 s.com*/ return modelAndView; }
From source file:org.osiam.addons.selfadministration.exception.OsiamExceptionHandler.java
@ExceptionHandler(OsiamClientException.class) protected ModelAndView handleConflict(OsiamClientException ex, HttpServletResponse response) { LOGGER.log(Level.WARNING, AN_EXCEPTION_OCCURED, ex); response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); modelAndView.addObject(KEY, "registration.form.error"); setLoggingInformation(ex);/* w w w . j a v a 2 s .c o m*/ return modelAndView; }
From source file:org.osiam.addons.selfadministration.exception.OsiamExceptionHandler.java
@ExceptionHandler(OsiamException.class) protected ModelAndView handleException(OsiamException ex, HttpServletResponse response) { LOGGER.log(Level.WARNING, AN_EXCEPTION_OCCURED, ex); response.setStatus(ex.getHttpStatusCode()); modelAndView.addObject(KEY, ex.getKey()); setLoggingInformation(ex);/* ww w .j av a 2 s . c o m*/ return modelAndView; }
From source file:org.osiam.addons.selfadministration.exception.OsiamExceptionHandler.java
@ExceptionHandler(RuntimeException.class) protected ModelAndView handleException(RuntimeException ex, HttpServletResponse response) { LOGGER.log(Level.WARNING, AN_EXCEPTION_OCCURED, ex); response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); modelAndView.addObject(KEY, "registration.exception.message"); setLoggingInformation(ex);/*from w w w.ja va 2s .c o m*/ return modelAndView; }
From source file:ca.uhn.fhir.rest.server.servlet.ServletRestfulResponse.java
@Override public Object sendAttachmentResponse(IBaseBinary bin, int stausCode, String contentType) throws IOException { addHeaders();//from www .ja v a 2s. c om HttpServletResponse theHttpResponse = getRequestDetails().getServletResponse(); theHttpResponse.setStatus(stausCode); theHttpResponse.setContentType(contentType); if (bin.getContent() == null || bin.getContent().length == 0) { return null; } else { theHttpResponse.setContentLength(bin.getContent().length); ServletOutputStream oos = theHttpResponse.getOutputStream(); oos.write(bin.getContent()); oos.close(); return null; } }
From source file:arena.web.view.DownloadView.java
@Override @SuppressWarnings("unchecked") protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { response.setStatus(HttpServletResponse.SC_OK); String mt = (mimeTypeParam != null ? (String) model.get(mimeTypeParam) : this.mimeType); if (mt != null) { response.setContentType(this.mimeType); }//from w w w . ja va 2 s. c o m Object contentObj = model.get(this.contentParam); String fileName = ServletUtils.replaceWildcards(this.filenamePattern, this.allowRequestArgs, model, request); if (!fileName.equals("")) { String rfc2047Name = javax.mail.internet.MimeUtility.encodeText(fileName, "UTF-8", null); String fullHeader = "attachment;filename=" + rfc2047Name; response.setHeader("Content-Disposition", fullHeader); } ServletOutputStream out = response.getOutputStream(); if (contentObj instanceof byte[]) { byte[] content = (byte[]) model.get(this.contentParam); response.setContentLength(content == null ? 0 : content.length); if (content != null && content.length > 0) { out.write(content); } } else if (contentObj instanceof InputStream) { InputStream content = (InputStream) contentObj; byte[] buffer = new byte[response.getBufferSize()]; int read = 0; while ((read = content.read(buffer)) >= 0) { out.write(buffer, 0, read); } if (this.closeStream) { content.close(); } } }