List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:org.codice.ddf.security.filter.websso.WebSSOFilter.java
/** * Sends the given response code back to the caller. * * @param code HTTP response code for this request * @param response the servlet response object *///from www . j a v a2 s. c om private void returnSimpleResponse(int code, HttpServletResponse response) { try { LOGGER.debug("Sending response code {}", code); response.setStatus(code); if (code >= 400) { response.sendError(code); } else { response.setContentLength(0); } response.flushBuffer(); } catch (IOException ioe) { LOGGER.debug("Failed to send auth response", ioe); } }
From source file:ch.sbb.releasetrain.jsfbootadapter.FileDownloadUtil.java
@RequestMapping(value = "/static/**", method = RequestMethod.GET) public void getFile(HttpServletResponse response, HttpServletRequest request) { try {/*from w ww . java 2 s . c o m*/ String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); PathMatchingResourcePatternResolver res = new PathMatchingResourcePatternResolver(); Resource template = res.getResource(path); if (!template.exists()) { log.info("file n/a... " + path); return; } org.apache.commons.io.IOUtils.copy(template.getInputStream(), response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { log.info("Error writing file to output stream", ex); } }
From source file:com.cognifide.aet.rest.LockServlet.java
@Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("PUT: " + req.toString()); }/*from w w w . j av a2 s .co m*/ resp.setContentType(APPLICATION_JSON_CONTENT_TYPE); String value = req.getParameter(VALUE_PARAM); String key = getKey(req); if (StringUtils.isBlank(key) || StringUtils.isBlank(value)) { resp.setStatus(404); } else { lockService.setLock(key, value); } resp.flushBuffer(); }
From source file:org.mule.transport.servlet.ServletResponseWriter.java
/** * Writes an empty {@link javax.servlet.http.HttpServletResponse}. * * @param servletResponse response object * @param httpHeaders headers to be set in the response object. Can be null. * @throws IOException// w w w.j ava 2 s . c om */ public void writeEmptyResponse(HttpServletResponse servletResponse, Map<String, String> httpHeaders) throws IOException { addHeaders(servletResponse, httpHeaders); servletResponse.setStatus(HttpServletResponse.SC_NO_CONTENT); if (feedbackOnEmptyResponse) { servletResponse.setStatus(HttpServletResponse.SC_OK); servletResponse.getWriter().write("Action was processed successfully. There was no result"); } servletResponse.flushBuffer(); }
From source file:org.surfnet.oaaas.auth.AuthorizationServerFilter.java
protected void sendError(HttpServletResponse response, int statusCode, String reason) { LOG.warn("No valid access-token on request. Will respond with error response: {} {}", statusCode, reason); try {/*from w ww .jav a 2 s . co m*/ response.sendError(statusCode, reason); response.flushBuffer(); } catch (IOException e) { throw new RuntimeException(reason, e); } }
From source file:com.oak_yoga_studio.controller.CustomerController.java
@RequestMapping(value = "/image/{id}", method = RequestMethod.GET) public void getUserImage(Model model, @PathVariable int id, HttpServletResponse response) { try {// w w w. j ava2 s . com Customer c = customerService.getCustomerById(id); if (c != null) { OutputStream out = response.getOutputStream(); out.write(c.getProfilePicture()); response.flushBuffer(); } } catch (IOException ex) { Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.oak_yoga_studio.controller.CustomerController.java
/** * In order to upload the users profile picture * * @param model/*from ww w . j a v a 2 s . c o m*/ * @param id * @param response */ @RequestMapping(value = "/profileImage/{id}", method = RequestMethod.GET) public void getProfileImage(Model model, @PathVariable int id, HttpServletResponse response) { try { Customer c = customerService.getCustomerById(id); if (c != null) { OutputStream out = response.getOutputStream(); out.write(c.getProfilePicture()); response.flushBuffer(); } } catch (IOException ex) { Logger.getLogger(CustomerController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.treeptik.cloudunit.controller.MonitoringController.java
/** * * Is a wrapper to cAdvisor API/* ww w . java 2 s . com*/ * * @param containerName * @throws ServiceException * @throws CheckException */ @RequestMapping(value = "/api/containers/docker/{containerName}", method = RequestMethod.GET) public void infoContainer(HttpServletRequest request, HttpServletResponse response, @PathVariable String containerName) throws ServiceException, CheckException { String containerId = monitoringService.getFullContainerId(containerName); String responseFromCAdvisor = monitoringService.getJsonFromCAdvisor(containerId); if (logger.isDebugEnabled()) { logger.debug("containerId=" + containerId); logger.debug("responseFromCAdvisor=" + responseFromCAdvisor); } try { response.getWriter().write(responseFromCAdvisor); response.flushBuffer(); } catch (Exception e) { logger.error("error during write and flush response", containerName); } }
From source file:com.digitalizat.control.TdocController.java
@RequestMapping(value = "obtenerFichero/{codigo}") public void obtenerFichero(@PathVariable(value = "codigo") String codigo, HttpServletResponse response) throws FileNotFoundException, IOException, Exception { Document doc = tdocManager.getDocument(Integer.valueOf(codigo)); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=" + doc.getFileName().replace(" ", "")); InputStream is = new FileInputStream(doc.getBasePath() + doc.getFileName()); IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); }
From source file:gob.osinergmin.inpsweb.controller.DocumentoAdjuntoController.java
@RequestMapping(value = "/descargaArchivoAlfresco", method = RequestMethod.GET) //public @ResponseBody Map<String, Object> descargaArchivoAlfresco(DocumentoAdjuntoDTO filtro){ public void descargaArchivoAlfresco(DocumentoAdjuntoDTO filtro, HttpServletResponse response) { LOG.info("procesando descargaArchivoAlfresco--->" + filtro.getNombreArchivo()); InputStream is = documentoAdjuntoServiceNeg.descargarDatosAlfresco(filtro); try {/*from w w w . j a v a2 s . c o m*/ if (is == null) { response.getWriter().write("Error al insertar Documento"); return; } String nombreFichero = filtro.getNombreArchivo(); response.setHeader("Content-Disposition", "attachment; filename=\"" + nombreFichero + "\""); IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (Exception ex) { LOG.info("--->" + ex.getMessage()); LOG.info("Error writing file to output stream. Filename was '" + filtro.getNombreArchivo() + "'"); throw new RuntimeException("IOError writing file to output stream"); } }