Examples of ServletOutputStream


Examples of javax.servlet.ServletOutputStream

   * @see javax.servlet.GenericServlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
   */
  public void service(ServletRequest req, ServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    ServletOutputStream sos = res.getOutputStream();
    System.out.println("buffer size is " + res.getBufferSize());
    res.setBufferSize(20000);
    sos.print("String1<br/>");
    sos.print("String2<br/>");
    if(res.isCommitted()){
      sos.print("Oh well, buffering did not work");
    }
    else{
      sos.print("Buffering is working well");
    }
    res.reset();
    sos.print("Hello world");
  }
View Full Code Here

Examples of javax.servlet.ServletOutputStream

        {
          response.setContentType(this.getMimeType(fileName));
        }
       
        // send the output.
        ServletOutputStream outStream = response.getOutputStream();
        BufferedOutputStream bufferedOutStream = new BufferedOutputStream(outStream);
        bufferedOutStream.write(buffer, 0, buffer.length);
        bufferedOutStream.flush();
        bufferedOutStream.close();
      }//end of if(fileID > 0)
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    } else {
      response.setContentType("image/gif");
      buffer = spacerGif;
    }
    // send the output.
    ServletOutputStream outStream = response.getOutputStream();
    BufferedOutputStream bufferedOutStream = new BufferedOutputStream(outStream);
    bufferedOutStream.write(buffer, 0, buffer.length);
    bufferedOutStream.flush();
    bufferedOutStream.close();
  }
View Full Code Here

Examples of javax.servlet.ServletOutputStream

            }
            response.setHeader("Content-disposition", "filename=\"" + image + "\";");
            response.setContentType(contentType);
            // Write out the image to the user.
            InputStream in = null;
            ServletOutputStream out = null;
            try {
                in = new BufferedInputStream(new FileInputStream(image));
                out = response.getOutputStream();

                // Set the size of the file.
                response.setContentLength((int)image.length());

                // Use a 1K buffer.
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) != -1) {
                    out.write(buf, 0, len);
                }
            }
            finally {
                try {
                    in.close();
                }
                catch (Exception ignored) {
                }
                try {
                    out.close();
                }
                catch (Exception ignored) {
                }
            }
        }
View Full Code Here

Examples of javax.servlet.ServletOutputStream

      if (contextMimeType != null)
      {
        response.setContentType(contextMimeType);
      }

      final ServletOutputStream outputStream = response.getOutputStream();
      IOUtils.getInstance().copyStreams(zin, outputStream);
      outputStream.flush();
    }
    zin.close();
  }
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    try
    {
      final MasterReport report = ReportGenerator.getInstance().parseReport(reportUrl);
      response.setContentType("application/zip");

      final ServletOutputStream stream = response.getOutputStream();
      HtmlReportUtil.createZIPHTML(report, stream, "report.html");
      stream.flush();
    }
    catch (ResourceException e)
    {
      log("Failed to parse report", e);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    try
    {
      final MasterReport report = ReportGenerator.getInstance().parseReport(reportUrl);
      response.setContentType("application/vnd.ms-excel");

      final ServletOutputStream stream = response.getOutputStream();
      ExcelReportUtil.createXLS(report, stream);
      stream.flush();
    }
    catch (ResourceException e)
    {
      log("Failed to parse report", e);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    try
    {
      final MasterReport report = ReportGenerator.getInstance().parseReport(reportUrl);
      response.setContentType("text/plain");

      final ServletOutputStream stream = response.getOutputStream();
      PlainTextReportUtil.createPlainText(report, stream);
      stream.flush();
    }
    catch (ResourceException e)
    {
      log("Failed to parse report", e);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    try
    {
      final MasterReport report = ReportGenerator.getInstance().parseReport(reportUrl);
      response.setContentType("text/html");

      final ServletOutputStream stream = response.getOutputStream();
      HtmlReportUtil.createStreamHTML(report, stream);
      stream.flush();
    }
    catch (ResourceException e)
    {
      log("Failed to parse report", e);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

Examples of javax.servlet.ServletOutputStream

    try
    {
      final MasterReport report = ReportGenerator.getInstance().parseReport(reportUrl);
      response.setContentType("application/pdf");

      final ServletOutputStream stream = response.getOutputStream();
      if (PdfReportUtil.createPDF(report, stream) == false)
      {
        log("Failed to process the report");
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
      }
      stream.flush();
    }
    catch (ResourceException e)
    {
      log("Failed to parse report", e);
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.