List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:nl.strohalm.cyclos.controls.customization.documents.ViewDocumentAction.java
@Override protected ActionForward executeAction(final ActionContext context) throws Exception { final PreviewDocumentForm form = context.getForm(); final long documentId = form.getDocumentId(); if (documentId < 1) { throw new ValidationException(); }// www. j a v a 2 s . com final StaticDocument document = (StaticDocument) documentService.load(documentId, StaticDocument.Relationships.BINARY_FILE); final BinaryFile binaryFile = document.getBinaryFile(); final HttpServletResponse response = context.getResponse(); responseHelper.setDownload(response, binaryFile.getName()); response.setContentType(binaryFile.getContentType()); response.setContentLength(binaryFile.getSize()); response.setDateHeader("Last-Modified", binaryFile.getLastModified().getTimeInMillis()); IOUtils.copy(binaryFile.getContents().getBinaryStream(), response.getOutputStream()); response.flushBuffer(); return null; }
From source file:com.liangc.hq.base.web.AvailabilityBaseServlet.java
protected void sendIcon(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType("image/gif"); IconBytes icon = (IconBytes) iconData.get(url); response.setContentLength(icon.getLength()); response.getOutputStream().write(icon.getBytes()); response.flushBuffer(); }
From source file:nl.strohalm.cyclos.controls.BaseAjaxAction.java
@Override protected final ActionForward executeAction(final ActionContext context) throws Exception { final HttpServletRequest request = context.getRequest(); final HttpServletResponse response = context.getResponse(); // Prepare the response headers final ContentType contentType = contentType(); contentType.processResponse(response); responseHelper.setEncoding(response); responseHelper.setNoCache(response); // Render the response try {/*from w ww .j av a 2s. c om*/ renderContent(context); response.flushBuffer(); } catch (final Exception e) { if (CLIENT_ABORT_EXCEPTION != null && CLIENT_ABORT_EXCEPTION.isInstance(e)) { // Nothing to do - the client has just cancelled the connection } else { handleException(request, response, e); } } // The response is now complete - return null return null; }
From source file:com.digitaslbi.helios.mock.service.controllers.FileListingController.java
@RequestMapping(value = "/file/{fileName}", method = RequestMethod.GET) public void downloadFile(@PathVariable("fileName") String fileName, HttpServletResponse response) { System.out.println("Parameter->" + fileName); try {//from w w w . j a va2s . c om File selectedFile = (File) files.get(fileName); if (selectedFile != null && selectedFile.isIsFile()) { InputStream inputStream = delegate.getS3Object(selectedFile.getFullPath()); if (inputStream != null) { IOUtils.copy(inputStream, response.getOutputStream()); response.flushBuffer(); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.bonitasoft.web.designer.controller.PreviewController.java
/** * Send redirect to the Rest API/* w w w .j a v a2 s . co m*/ */ @RequestMapping("/preview/{artifact}/API/**") public void proxyAPICall(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { String queryString = isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString(); response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT); response.addHeader("Location", "/bonita/API/" + RequestMappingUtils.extractPathWithinPattern(request) + queryString); response.flushBuffer(); } catch (IOException e) { String message = "Error while redirecting API call"; logger.error(message, e); throw new ServletException(message, e); } }
From source file:org.commonfarm.web.ECSideFilter.java
public void doAjaxFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("UTF-8"); String easyListName = getEasyList(request); String easyDataAccessName = getEasyDataAccess(request); String findAjaxZoneAtClient = request.getParameter(TableConstants.AJAX_FINDZONE_CLIENT); if (findAjaxZoneAtClient != null && ("false".equalsIgnoreCase(findAjaxZoneAtClient) || "0".equals(findAjaxZoneAtClient))) { ECSideAjaxResponseWrapper bufferResponseWrapper = new ECSideAjaxResponseWrapper(response); try {/* ww w . j a v a 2 s . c om*/ String ectableId = request.getParameter(TableConstants.EXTREME_COMPONENTS_INSTANCE); if (easyListName != null) { easyDataAccessHandler.easyList(request, bufferResponseWrapper, getEasyListModelBean(request, easyListName)); } else if (easyDataAccessName != null) { String sqlName = getSqlName(request); easyDataAccessHandler.dataAccess(getDataAccessModelBean(request, easyDataAccessName), sqlName, request, response); } chain.doFilter(request, bufferResponseWrapper); String zone = bufferResponseWrapper.findSubstring(ECSideUtils.getAjaxBegin(ectableId), ECSideUtils.getAjaxEnd(ectableId)); HttpServletResponse originalResponse = bufferResponseWrapper.getOriginalResponse(); originalResponse.flushBuffer(); originalResponse.getOutputStream().write(zone.getBytes("UTF-8")); originalResponse.flushBuffer(); originalResponse.getOutputStream().close(); } catch (Exception e) { e.printStackTrace(); } } else { if (easyListName != null) { easyDataAccessHandler.easyList(request, response, getEasyListModelBean(request, easyListName)); } else if (easyDataAccessName != null) { String sqlName = getSqlName(request); easyDataAccessHandler.dataAccess(getDataAccessModelBean(request, easyDataAccessName), sqlName, request, response); } chain.doFilter(request, response); } }
From source file:de.itsvs.cwtrpc.security.AbstractRpcFailureHandler.java
protected void writeUnexpectedException(HttpServletRequest request, HttpServletResponse response, Throwable exception) throws IOException { if (CwtRpcUtils.getRpcSessionInvalidationPolicy(request).isInvalidateOnUnexpectedException()) { invalidateSession(request);// ww w . j a v a 2 s .c o m } response.reset(); addNoCacheResponseHeaders(request, response); RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, exception); response.flushBuffer(); }
From source file:javarestart.controllers.ApplicationController.java
@RequestMapping(value = "/{applicationName}", params = { "resource" }, method = RequestMethod.GET) public void loadResource(@RequestParam(value = "resource") String resourceName, @PathVariable("applicationName") String applicationName, HttpServletResponse response) throws Exception { AppResourceProvider resourceProvider = getOrRegisterApp(applicationName); URLConnection resource = null; try {//w w w .j a v a 2s. c o m resource = resourceProvider.load(resourceName); resource.connect(); response.setContentLength(resource.getContentLength()); IOUtils.copy(resource.getInputStream(), response.getOutputStream()); response.flushBuffer(); logger.info("Class or resource loaded: " + resourceName); } catch (ResourceNotFoundException e) { logger.warning(e.toString()); response.sendError(404); } }
From source file:org.magnum.dataup.controller.VideoSvc.java
/** * Get video stream data/*from w w w .j a v a 2 s . c o m*/ * * @param id * Video identifier */ @RequestMapping(value = VideoSvcApi.VIDEO_DATA_PATH, method = RequestMethod.GET) public void getData(@PathVariable Long id, HttpServletResponse response) { try { VideoFileManager fileManager = VideoFileManager.get(); Video video = repository.findOne(id); if (fileManager.hasVideoData(video)) { response.setContentType("video/mp4"); fileManager.copyVideoData(video, response.getOutputStream()); response.setStatus(200); response.flushBuffer(); } else { response.setStatus(404); } } catch (IOException e) { response.setStatus(404); } }
From source file:org.fenixedu.academic.ui.struts.action.student.candidacy.FirstTimeEnrolmentDocuments.java
public ActionForward showSummaryFile(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { CandidacySummaryFile file = ((StudentCandidacy) getDomainObject(request, "candidacyID")).getSummaryFile(); response.reset();/*w w w. j av a 2s.c o m*/ try { response.getOutputStream().write(file.getContent()); response.setContentLength(file.getContent().length); response.setContentType("application/pdf"); response.flushBuffer(); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }