List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:org.nuxeo.ecm.platform.io.client.ImportExportActionBean.java
private static void handleRedirect(HttpServletResponse response, String url) throws IOException { response.resetBuffer();/*from w w w .j av a2s . c om*/ response.sendRedirect(url); response.flushBuffer(); getHttpServletRequest().setAttribute(NXAuthConstants.DISABLE_REDIRECT_REQUEST_KEY, true); FacesContext.getCurrentInstance().responseComplete(); }
From source file:org.eclipse.jgit.lfs.server.fs.FileLfsServlet.java
/** * Send an error response./* ww w .j av a2s .c o m*/ * * @param rsp * the servlet response * @param status * HTTP status code * @param message * error message * @throws IOException * on failure to send the response * @since 4.6 */ protected static void sendError(HttpServletResponse rsp, int status, String message) throws IOException { rsp.setStatus(status); PrintWriter writer = rsp.getWriter(); gson.toJson(new Error(message), writer); writer.flush(); writer.close(); rsp.flushBuffer(); }
From source file:info.magnolia.module.servletsanity.support.ServletAssert.java
public static void flush(HttpServletResponse response) throws IOException { StringBuffer sb = tls.get();//from www . j a va 2s.co m if (sb != null) { response.getWriter().write(sb.toString()); response.getWriter().write("TEST COMPLETED<br/>"); response.getWriter().flush(); response.flushBuffer(); tls.set(new StringBuffer()); } }
From source file:io.druid.server.AsyncQueryForwardingServlet.java
private static void handleException(HttpServletResponse response, ObjectMapper objectMapper, Exception exception) throws IOException { if (!response.isCommitted()) { final String errorMessage = exception.getMessage() == null ? "null exception" : exception.getMessage(); response.resetBuffer();//from w w w . ja va2 s . c om response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); objectMapper.writeValue(response.getOutputStream(), ImmutableMap.of("error", errorMessage)); } response.flushBuffer(); }
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 {/*from w ww . j a v a 2 s .com*/ 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); } } }
From source file:com.cognifide.aet.rest.ConfigsServlet.java
private void flushResponseBuffer(HttpServletRequest req, HttpServletResponse resp) { try {// w ww . j a va2 s . c o m resp.flushBuffer(); } catch (IOException e) { LOGGER.error("error while flushing response buffer for request: '{}' and response: '{}'", req, resp, e); } }
From source file:net.nan21.dnet.core.web.security.DefaultNotAuthenticatedEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.setStatus(HttpServletResponse.SC_FORBIDDEN); response.getWriter().write("Not authenticated"); response.flushBuffer(); }
From source file:io.github.chibat.selva.response.JsonResponse.java
public void execute(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { response.setStatus(this.status()); response.setContentType(this.type()); new ObjectMapper().writeValue(response.getWriter(), model); response.flushBuffer(); }
From source file:com.adaptris.core.http.jetty.StandardResponseProducer.java
private void commitResponse(AdaptrisMessage msg, HttpServletResponse response) throws ProduceException { try {//www . java 2 s . co m handlePayload(msg, response); if (flushBuffers()) { response.flushBuffer(); } } catch (IOException | CoreException e) { if (forwardConnectionException()) { throw ExceptionHelper.wrapProduceException(e); } else { log.trace("Failed to commit response to HTTP; client disconnected?"); } } }
From source file:de.iew.raspimotion.controllers.MotionJpegController.java
public void sendImageAsJpeg(FileDescriptor file, HttpServletResponse response) throws Exception { sendImageAsJpeg(response.getOutputStream(), file); response.flushBuffer(); }