List of usage examples for javax.servlet.http HttpServletResponse getOutputStream
public ServletOutputStream getOutputStream() throws IOException;
From source file:org.openxdata.server.servlet.FormDownloadServlet.java
private void downloadForms(HttpServletRequest request, HttpServletResponse response) throws IOException { String studyId = request.getParameter("studyId"); if (studyId == null) formDownloadService.downloadForms(response.getOutputStream(), request.getParameter(OpenXDataConstants.REQUEST_PARAM_FORM_SERIALIZER), request.getParameter(OpenXDataConstants.REQUEST_PARAM_LOCALE)); else/* w ww. j a va2 s .c o m*/ formDownloadService.downloadForms(Integer.parseInt(studyId), response.getOutputStream(), request.getParameter(OpenXDataConstants.REQUEST_PARAM_FORM_SERIALIZER), request.getParameter(OpenXDataConstants.REQUEST_PARAM_LOCALE)); }
From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet2.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("image/png"); OutputStream outputStream = response.getOutputStream(); CategoryDataset dataset = createDataset(); JFreeChart chart = getChart(dataset); int width = 800; int height = 250; ChartUtilities.writeChartAsPNG(outputStream, chart, width, height); }
From source file:com.gantzgulch.sharing.controller.SharedFileDownloadController.java
@RequestMapping(method = RequestMethod.GET) public void showUploadForm(@RequestParam(required = true) String id, final HttpServletResponse response, final HttpServletRequest request) { SharedFile sharedFile = sharedFileManager.findById(id); InputStream is = null;//ww w . j av a 2s. c o m OutputStream os = null; try { is = sharedFileManager.download(id, userManager.getCurrentUser()); os = response.getOutputStream(); response.setHeader("Content-Disposition", "attachment; filename=\"" + sharedFile.getFilename() + "\""); response.setHeader("Content-Type", "application/force-download"); if (sharedFile.getSize() < Integer.MAX_VALUE) { response.setContentLength((int) sharedFile.getSize()); } IOUtils.copyLarge(is, os); os.flush(); } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { IOUtils.closeQuietly(is); } }
From source file:de.mpg.imeji.presentation.servlet.ExportServlet.java
/** * {@inheritDoc}// w ww.jav a 2 s . co m */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { SessionBean session = getSessionBean(req, resp); String instanceName = session.getInstanceName(); User user = session.getUser(); try { ExportManager exportManager = new ExportManager(resp.getOutputStream(), user, req.getParameterMap()); String exportName = instanceName + "_"; exportName += new Date().toString().replace(" ", "_").replace(":", "-"); if (exportManager.getContentType().equalsIgnoreCase("application/xml")) { exportName += ".xml"; } if (exportManager.getContentType().equalsIgnoreCase("application/zip")) { exportName += ".zip"; } resp.setHeader("Connection", "close"); resp.setHeader("Content-Type", exportManager.getContentType()); resp.setHeader("Content-disposition", "filename=" + exportName); resp.setStatus(HttpServletResponse.SC_OK); SearchResult result = exportManager.search(); exportManager.export(result); resp.getOutputStream().flush(); } catch (HttpResponseException he) { resp.sendError(he.getStatusCode(), he.getMessage()); } catch (Exception e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } }
From source file:org.energyos.espi.datacustodian.web.api.ReadingTypeRESTController.java
@RequestMapping(value = Routes.ROOT_READING_TYPE_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml") @ResponseBody/*from w ww.j a va 2s . c om*/ public void show(HttpServletResponse response, @PathVariable Long readingTypeId, @RequestParam Map<String, String> params) throws IOException, FeedException { response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE); exportService.exportReadingType(readingTypeId, response.getOutputStream(), new ExportFilter(params)); }
From source file:org.magnum.dataup.MyVideoController.java
@RequestMapping(value = "/video/{id}/data", method = RequestMethod.GET) @Streaming// www . j a v a 2 s.co m Response getData(@PathVariable("id") long id, HttpServletResponse response) { Video v = videos.get(id); if (v == null) { response.setStatus(404); return null; } try { VideoFileManager vfm = VideoFileManager.get(); vfm.copyVideoData(v, response.getOutputStream()); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:io.dacopancm.jfee.managedController.ReportBean.java
public void sendPdf(JasperPrint jasperPrint, String filename) throws JRException, IOException { HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance() .getExternalContext().getResponse(); httpServletResponse.addHeader("Content-disposition", "attachment; filename=" + filename + ".pdf"); ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream(); JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream); FacesContext.getCurrentInstance().responseComplete(); }
From source file:it.cilea.osd.jdyna.web.controller.AutocompleteUsersView.java
protected void renderMergedOutputModel(Map model, HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception { response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); List<DTOAutocomplete> users = (List<DTOAutocomplete>) model.get("result"); String xml = new AjaxXmlBuilder().addItems(users, "display", "id", true).toString(); ServletOutputStream out = response.getOutputStream(); out.print(xml);/*from w w w . jav a 2 s . com*/ out.close(); }
From source file:org.fishwife.jrugged.spring.StatusController.java
private void writeOutCurrentStatusInResponseBody(HttpServletResponse resp, Status currentStatus) throws IOException { resp.setHeader("Content-Type", "text/plain;charset=utf-8"); String body = currentStatus + "\n"; byte[] bytes = body.getBytes(); resp.setHeader("Content-Length", bytes.length + ""); OutputStream out = resp.getOutputStream(); out.write(bytes);//from www . jav a 2 s .c o m out.flush(); out.close(); }