List of usage examples for javax.servlet.http HttpServletResponse flushBuffer
public void flushBuffer() throws IOException;
From source file:co.com.soinsoftware.altablero.request.TeacherRequestHandler.java
@RequestMapping(value = TEACHER_REPORT_GENERATE_PAGE, method = RequestMethod.POST) public void generateReports( @RequestParam(value = CLASSROOM_ID_REQUEST_PARAM, required = false) final Integer idClassRoom, @RequestParam(value = PERIOD_REQUEST_PARAM, required = false) final Integer idPeriod, HttpServletResponse response) { try {/*from w w w . j a v a2 s .c om*/ final UserBO logedUser = this.getLogeduser(); final int idSchool = this.getIdSchool(logedUser); InputStream is = this.generateReports(idSchool, idClassRoom, idPeriod); response.setHeader("Content-Disposition", "attachment; filename=boletines.zip"); IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { LOGGER.error(ex.getMessage(), ex); } }
From source file:marytts.http.controllers.MaryController.java
/** * Method to retrieve a signal already synthesized using the method {@link synthesize(String)} or the method {@link process(String)} * * @param response the response to fill * @throws Exception in case of failing (no synthesis called before, ...) *///from w ww .j a v a 2 s . c o m @RequestMapping("/getSynthesizedSignal") public void getSynthesizedSignal(HttpServletResponse response) throws Exception { if (ais == null) { throw new RuntimeException("No synthesis achieved => no signal to get !"); } response.setContentType("audio/x-wav"); AudioSystem.write(ais, AudioFileFormat.Type.WAVE, response.getOutputStream()); response.flushBuffer(); }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.ProposalBudgetSubAwardController.java
@Transactional @RequestMapping(params = "methodToCall=viewSubAwardXml") public void viewXml(@RequestParam("subAwardNumber") Integer subAwardNumber, @ModelAttribute("KualiForm") ProposalBudgetForm form, HttpServletResponse response) { BudgetSubAwards subAward = getSubAwardByNumber(subAwardNumber, form); try {// www .j a va 2 s . c o m ByteArrayInputStream inputStream = new ByteArrayInputStream( subAward.getSubAwardXmlFileData().getBytes()); KRADUtils.addAttachmentToResponse(response, inputStream, "text/xml", createXMLFileName(subAward), subAward.getSubAwardXmlFileData().length()); response.flushBuffer(); } catch (Exception e) { LOG.error("Error while downloading attachment"); throw new RuntimeException("IOException occurred while downloading attachment", e); } }
From source file:org.lsug.quota.QuotaEditFileEntryAction.java
protected void writeJSON(PortletRequest portletRequest, ActionResponse actionResponse, Object json) throws IOException { HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); response.setContentType(ContentTypes.APPLICATION_JSON); ServletResponseUtil.write(response, json.toString()); response.flushBuffer(); setForward(portletRequest, COMMON_NULL); }
From source file:com.github.viktornar.controller.composer.ComposeController.java
@RequestMapping(value = "/download/{id}", method = RequestMethod.GET) public void getFile(@PathVariable("id") String id, HttpServletResponse response) { try {//from w w w . j a va 2s . c o m String _atlasFolder = format("%s/%s", atlasFolder, id); String _atlasName = format("%s%s.pdf", atlasNamePrefix, id); String filePathToBeServed = format("%s/%s", _atlasFolder, _atlasName); File fileToDownload = new File(filePathToBeServed); InputStream inputStream = new FileInputStream(fileToDownload); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", format("attachment; filename=%s", _atlasName)); IOUtils.copy(inputStream, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { throw new RuntimeException("IOError writing file to output stream"); } }
From source file:com.its.web.controllers.LicensesManagerController.java
@RequestMapping(value = "generateLicenseFile.do", method = RequestMethod.GET) public void generateLicenseFile(@RequestParam("licenseId") Long licenseId, HttpServletResponse response) { log.debug("generateLicenseFile------------->" + licenseId); //read from database License currentLicense = licensesService.getById(licenseId); InputStream is = licensesService.generateLicenseFile(currentLicense); String fileName = "License_File_" + currentLicense.getClientName().replace(" ", "_") + ".its"; response.setContentType("application/force-download"); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try {//www . ja v a 2 s.c om // copy it to response's OutputStream IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.openmrs.module.bannerprototype.web.controller.bannerprototypeManageController.java
@RequestMapping(value = "/module/bannerprototype/report-entity-freq", method = RequestMethod.GET) public void getEntityFreqReport(HttpServletResponse response) { List<SofaDocument> documents = Context.getService(NLPService.class).getAllSofaDocuments(); ReportGenerator rg = new ReportGenerator(documents); String report = rg.generateEntityFrequencyReport(); try {//from ww w . jav a 2s . co m // get your file as InputStream InputStream is = new ByteArrayInputStream(report.getBytes()); // copy it to response's OutputStream org.apache.commons.io.IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { throw new RuntimeException("IOError writing file to output stream"); } }
From source file:org.ngrinder.infra.spring.Redirect404DispatcherServlet.java
/** * Redirect to error 404 when the /svn/ is not included in the path. * * @param request current HTTP requests * @param response current HTTP response * @throws Exception if preparing the response failed *///from w ww . j a va 2 s. c om protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception { if (!request.getPathInfo().startsWith("/svn/")) { if (request.getPathInfo().contains("/api")) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setContentType("application/json; charset=UTF-8"); String requestUri = urlPathHelper.getRequestUri(request); JsonObject object = new JsonObject(); object.addProperty(JSON_SUCCESS, false); object.addProperty(JSON_CAUSE, "API URL " + requestUri + " [" + request.getMethod() + "] does not exist."); response.getWriter().write(gson.toJson(object)); response.flushBuffer(); } else { if (pageNotFoundLogger.isWarnEnabled()) { String requestUri = urlPathHelper.getRequestUri(request); pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + requestUri + "] in DispatcherServlet with name '" + getServletName() + "'"); } response.sendRedirect("/error_404"); } } }
From source file:org.openmrs.module.bannerprototype.web.controller.bannerprototypeManageController.java
@RequestMapping(value = "/module/bannerprototype/report-all-notes", method = RequestMethod.GET) public void getAllNotesReport(HttpServletResponse response) { List<SofaDocument> documents = Context.getService(NLPService.class).getAllSofaDocuments(); ReportGenerator rg = new ReportGenerator(documents); String report = rg.generateAllNoteAndEntityReport(); try {/*from ww w. j ava2s.c o m*/ // get your file as InputStream InputStream is = new ByteArrayInputStream(report.getBytes()); // copy it to response's OutputStream org.apache.commons.io.IOUtils.copy(is, response.getOutputStream()); response.flushBuffer(); } catch (IOException ex) { throw new RuntimeException("IOError writing file to output stream"); } }
From source file:org.eclipse.smarthome.core.audio.internal.AudioServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { removeTimedOutStreams();/*from ww w . ja v a2 s .c om*/ final String streamId = StringUtils .substringBefore(StringUtils.substringAfterLast(req.getRequestURI(), "/"), "."); try (final InputStream stream = prepareInputStream(streamId, resp)) { if (stream == null) { logger.debug("Received request for invalid stream id at {}", req.getRequestURI()); resp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { IOUtils.copy(stream, resp.getOutputStream()); resp.flushBuffer(); } } catch (final AudioException ex) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } }