List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:org.hyperic.hq.ui.servlet.AvailabilityColorServlet.java
protected void sendErrorIcon(HttpServletRequest request, HttpServletResponse response) { try {/* w w w . j a v a 2 s . com*/ sendIcon(request, response, PX_ERR_URL); return; } catch (Exception e) { log.debug("can't send error icon: ", e); } // if we made it this far, we can't even get the error icon // sent. bail out with an internal server error. try { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.flushBuffer(); } catch (IOException e) { log.debug("can't commit server error response !? ", e); } }
From source file:org.eclipse.vorto.repository.web.AdminController.java
@RequestMapping(value = "/content", method = RequestMethod.GET) @Secured("ROLE_ADMIN") public void backupRepository(final HttpServletResponse response) throws Exception { byte[] backup = this.repositoryManager.backup(); response.setHeader(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + "vortobackup_" + SIMPLEDATEFORMAT.format(new Date()) + ".xml"); response.setContentLengthLong(backup.length); response.setContentType(APPLICATION_OCTET_STREAM); try {/* w w w . ja va2 s .c om*/ IOUtils.copy(new ByteArrayInputStream(backup), response.getOutputStream()); response.flushBuffer(); } catch (IOException e) { throw new RuntimeException("Error copying file.", e); } }
From source file:com.liangc.hq.base.web.AvailabilityServlet.java
protected void sendErrorIcon(HttpServletRequest request, HttpServletResponse response) { try {/*from w w w.j a v a 2 s . c o m*/ sendIcon(request, response, ICON_ERR_URL); return; } catch (Exception e) { log.debug("can't send error icon: "); } // if we made it this far, we can't even get the error icon // sent. bail out with an internal server error. try { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.flushBuffer(); } catch (IOException e) { log.debug("can't commit server error response !? "); } }
From source file:org.nsesa.editor.gwt.an.amendments.server.service.XMLExportService.java
@Override public void export(AmendmentContainerDTO object, HttpServletResponse response) throws IOException { try {/*from ww w. java2 s . c om*/ response.setContentType("text/xml"); response.setHeader("Content-Disposition", "attachment;filename=" + object.getAmendmentContainerID() + ".xml"); response.setCharacterEncoding("UTF8"); byte[] bytes = object.getBody().getBytes("utf-8"); IOUtils.copy(new ByteArrayInputStream(bytes), response.getOutputStream()); response.setContentLength(bytes.length); response.flushBuffer(); } catch (IOException e) { throw new RuntimeException("Failed to xml export", e); } }
From source file:org.hyperic.hq.ui.servlet.AvailabilityServlet.java
protected void sendErrorIcon(HttpServletRequest request, HttpServletResponse response) { try {/*from w w w.j a va 2s . co m*/ sendIcon(request, response, ICON_ERR_URL); return; } catch (Exception e) { log.debug("can't send error icon: ", e); } // if we made it this far, we can't even get the error icon // sent. bail out with an internal server error. try { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.flushBuffer(); } catch (IOException e) { log.debug("can't commit server error response !? ", e); } }
From source file:cs425.yogastudio.controller.ProductController.java
@RequestMapping(value = "/productpic/{id}", method = RequestMethod.GET) public void getUserImage(Model model, @PathVariable int id, HttpServletResponse response) { try {/*from w ww. j a va 2 s. co m*/ Product c = productService.get(id); if (c != null) { OutputStream out = response.getOutputStream(); if (c.getProductImage() == null) { System.out.println("###################no image"); } out.write(c.getProductImage()); response.flushBuffer(); } } catch (IOException ex) { //Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.rss.InformaRSSAction.java
@Override public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { final String encoding = System.getProperty("file.encoding", Charset.defaultCharset().name()); final ChannelIF channel = getRSSChannel(request); if (channel != null) { response.setContentType("text/xml; charset=" + encoding); final PrintWriter writer = response.getWriter(); final ChannelExporterIF exporter = new RSS_2_0_Exporter(writer, encoding); exporter.write(channel);/*from w w w. j a va2 s .co m*/ response.flushBuffer(); } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.getWriter().write(HttpStatus.getStatusText(HttpStatus.SC_NOT_FOUND)); response.getWriter().close(); } return null; }
From source file:com.ewcms.web.filter.render.TemplateSourceRender.java
/** * ?/*w w w.j av a 2s . c o m*/ * * @param response * @param uri ? * @return * @throws IOException */ protected boolean output(HttpServletResponse response, String uri) throws IOException { TemplateSource source = templateSourceService.getTemplateSourceByUniquePath(uri); if (source == null) { logger.debug("TemplateSource is not exist,uri is {}", uri); return false; } TemplatesrcEntity entity = source.getSourceEntity(); if (entity == null || entity.getSrcEntity() == null) { return false; } IOUtils.write(entity.getSrcEntity(), response.getOutputStream()); response.flushBuffer(); return true; }
From source file:ee.sk.hwcrypto.demo.controller.ViewController.java
@RequestMapping("/downloadContainer") public void downloadContainer(HttpServletResponse response) { Container container = session.getContainer(); String fileName = container.getDataFiles().get(0).getName() + ".bdoc"; response.setContentType(CONTAINER_MIME_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try {/*from www . j a v a 2 s.c o m*/ InputStream containerStream = container.saveAsStream(); ServletOutputStream outputStream = response.getOutputStream(); IOUtils.copy(containerStream, outputStream); response.flushBuffer(); } catch (IOException e) { log.error("Error Writing file content to output stream", e); } }
From source file:org.codice.ddf.pax.web.jetty.CsrfFilter.java
/** * Security audits, logs, and then responds with a 403. * * @param httpResponse response object//w w w. ja v a 2 s . c o m * @param msg logging & security audit message */ private void respondForbidden(HttpServletResponse httpResponse, String msg) { SecurityLogger.audit(msg); LOGGER.debug(msg); try { httpResponse.setStatus(HttpServletResponse.SC_FORBIDDEN); httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN); httpResponse.flushBuffer(); } catch (IOException ioe) { LOGGER.debug("Failed to send auth response: {}", ioe); } }