List of usage examples for javax.servlet.http HttpServletResponse getOutputStream
public ServletOutputStream getOutputStream() throws IOException;
From source file:org.jmesaweb.controller.MultiAjaxController.java
public ModelAndView table1(HttpServletRequest request, HttpServletResponse response) throws Exception { TableFacade tableFacade = createTableFacade("table1", request); String html = getHtml(tableFacade); byte[] contents = html.getBytes(); response.getOutputStream().write(contents); return null;/*from w w w.j a v a 2 s . c o m*/ }
From source file:org.jmesaweb.controller.MultiAjaxController.java
public ModelAndView table2(HttpServletRequest request, HttpServletResponse response) throws Exception { TableFacade tableFacade = createTableFacade("table2", request); String html = getHtml(tableFacade); byte[] contents = html.getBytes(); response.getOutputStream().write(contents); return null;/* ww w. jav a2s.c o m*/ }
From source file:com.redhat.rhn.frontend.action.systems.monitoring.ProbeGraphAction.java
private void writeChartToResponse(JFreeChart chartIn, HttpServletResponse resp) throws IOException { resp.setContentType(MIME_TYPE);/*from w w w.ja va 2 s.com*/ try { ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chartIn, DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); } catch (IOException e) { log.error("Error writing chart to OutputStream.", e); throw e; } }
From source file:org.efs.openreports.actions.ReportViewerAction.java
public String execute() { JasperPrint jasperPrint = (JasperPrint) ActionContext.getContext().getSession().get(ORStatics.JASPERPRINT); report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT); if (jasperPrint != null && jasperPrint.getPages() != null) { pageCount = jasperPrint.getPages().size(); }// ww w. j ava2 s . co m if (!"image".equals(submitType)) return SUCCESS; byte[] imageData = null; if (jasperPrint != null) { try { BufferedImage image = (BufferedImage) JasperPrintManager.printPageToImage(jasperPrint, pageIndex - 1, zoom); imageData = new SunPNGEncoderAdapter().encode(image); } catch (Exception e) { addActionError(e.getMessage()); log.error(e.toString()); } } if (imageData != null) { HttpServletResponse response = ServletActionContext.getResponse(); try { response.setContentLength(imageData.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(imageData, 0, imageData.length); ouputStream.flush(); ouputStream.close(); } catch (IOException ioe) { log.warn(ioe.toString()); } } return NONE; }
From source file:org.usip.osp.graphs.GraphServer.java
/** * Processes a GET request./*from w ww . jav a 2s . c o m*/ * * @param request * the request. * @param response * the response. * * @throws ServletException * if there is a servlet related problem. * @throws IOException * if there is an I/O problem. */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream out = response.getOutputStream(); prepResonse(response); String chart_id = request.getParameter("chart_id"); //$NON-NLS-1$ String sim_id = request.getParameter("sim_id"); //$NON-NLS-1$ String game_round = request.getParameter("game_round"); //$NON-NLS-1$ //String running_game_id = request.getParameter("running_game_id"); String game_values_table = request.getParameter("game_values_table"); //$NON-NLS-1$ Chart cci = new Chart(); if (chart_id != null) { cci = getChartByNameAndRound(chart_id, game_round, sim_id, game_values_table); } else { cci.setThis_chart(getDemoChart()); } writeChartAsPNG(out, cci); }
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 ww w.ja v a 2 s .c o 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:de.science.hack.jetstream.web.controller.DownloadController.java
private OutputStream prepareResponse(HttpServletResponse response) throws IOException { response.setContentType(MIME);//from w ww . j a va 2 s.c om String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", GLOBE); response.setHeader(headerKey, headerValue); return response.getOutputStream(); }
From source file:it.tidalwave.northernwind.frontend.util.InitializationDiagnosticsDispatcherServletDecorator.java
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void sendProcessingError(final @Nonnull Throwable t, final @Nonnull HttpServletResponse response) throws IOException { response.setStatus(500);//from w ww. ja v a2 s . c o m response.setContentType("text/html"); final PrintWriter pw = new PrintWriter(new PrintStream(response.getOutputStream(), true, "UTF-8")); pw.print("<html>\n<head>\n<title>Configuration Error</title>\n</head>\n<body>\n"); pw.print("<h1>Configuration Error</h1>\n<pre>\n"); pw.print(t.toString()); // t.printStackTrace(pw); pw.print("</pre>\n"); pw.print("<h2>Boot log</h2>\n<pre>\n"); pw.print(BootLogger.getLogContent()); pw.print("</pre></body>\n</html>"); pw.close(); response.getOutputStream().close(); }
From source file:com.impala.paga.all.QueryBanks.java
/** * //from ww w . j ava 2s . c om * @param request * @param response * @throws ServletException * , IOException */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream out = response.getOutputStream(); response.setContentType("text/plain;charset=UTF-8"); response.setDateHeader("Expires", new Date().getTime()); // Expiration // date response.setDateHeader("Date", new Date().getTime()); // Date and time try { // that the // message was // sent out.write(moneytransfer(request).getBytes()); } catch (JSONException ex) { Logger.getLogger(QueryBanks.class.getName()).log(Level.SEVERE, null, ex); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(QueryBanks.class.getName()).log(Level.SEVERE, null, ex); } out.flush(); out.close(); }
From source file:org.inbio.ait.web.ajax.controller.IndicatorsTreeController.java
private ModelAndView writeReponse(HttpServletRequest request, HttpServletResponse response, List<AutocompleteNode> acnList) throws Exception { response.setCharacterEncoding("ISO-8859-1"); response.setContentType("text/xml"); // Binary output ServletOutputStream out = response.getOutputStream(); if (acnList != null) { StringBuilder result = new StringBuilder(); result.append("<?xml version='1.0' encoding='ISO-8859-1'?><response>"); for (AutocompleteNode sp : acnList) { result.append("<node><id>" + sp.getItemId() + "</id>"); result.append("<name>" + sp.getItemName() + "</name></node>"); }/*ww w .j a v a 2s . co m*/ result.append("</response>"); out.println(result.toString()); } out.flush(); out.close(); return null; }