Package javax.servlet

Examples of javax.servlet.ServletOutputStream


    } else {
      throw new IllegalArgumentException("invalid download method " + download);
    }

    // Write the docmuent
    ServletOutputStream out = response.getOutputStream();
    doc.render(out, format);
    out.flush();
  }
View Full Code Here


        if (fbos.size() > 0)
        {
          response.setContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation");
          response.setHeader("Content-Disposition", "inline; filename=\"file.pptx\"");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
    }
    else
    {
      response.setContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation");
      response.setHeader("Content-Disposition", "inline; filename=\"file.pptx\"");
     
      JRPptxExporter exporter = new JRPptxExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

        if (fbos.size() > 0)
        {
          response.setContentType("text/xml");
          response.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\"");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType("text/xml");
      response.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\"");

      JRXmlExporter exporter = getExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
      if (startPageIndex >= 0)
      {
        exporter.setParameter(JRExporterParameter.START_PAGE_INDEX, Integer.valueOf(startPageIndex));
      }
      if (endPageIndex >= 0)
      {
        exporter.setParameter(JRExporterParameter.END_PAGE_INDEX, Integer.valueOf(endPageIndex));
      }
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

        if (fbos.size() > 0)
        {
          response.setContentType("application/vnd.oasis.opendocument.spreadsheet");
          response.setHeader("Content-Disposition", "inline; filename=\"file.ods\"");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
     
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType("application/vnd.oasis.opendocument.spreadsheet");
      response.setHeader("Content-Disposition", "inline; filename=\"file.ods\"");

      JROdsExporter exporter = new JROdsExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

         // Forward the invocation onto the JMX invoker
         Object value = mbeanServer.invoke(invokerName, "invoke", params, sig);
         if( returnValueAsAttribute == null || returnValueAsAttribute.booleanValue() == false )
         {
            MarshalledValue mv = new MarshalledValue(value);
            ServletOutputStream sos = response.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(sos);
            oos.writeObject(mv);
            oos.close();
         }
         else
         {
            request.setAttribute("returnValue", value);
         }
      }
      catch(Throwable t)
      {
         t = JMXExceptionDecoder.decode(t);
         // Unwrap any reflection InvocationTargetExceptions
         if( t instanceof InvocationTargetException )
         {
            InvocationTargetException ite = (InvocationTargetException) t;
            t = ite.getTargetException();
         }
         /* Wrap the exception in an InvocationException to distinguish
            between application and transport exceptions
         */
         InvocationException appException = new InvocationException(t);
         // Marshall the exception
         if( returnValueAsAttribute == null || returnValueAsAttribute.booleanValue() == false )
         {
            if (response.isCommitted())
            {
               // Cannot report back exception
               log.error("Invoke threw exception, and response is already committed", t);
            }
            else
            {
               response.resetBuffer();
               MarshalledValue mv = new MarshalledValue(appException);
               ServletOutputStream sos = response.getOutputStream();
               ObjectOutputStream oos = new ObjectOutputStream(sos);
               oos.writeObject(mv);
               oos.close();
            }
         }
View Full Code Here

         response.setContentType(RESPONSE_CONTENT_TYPE);
         MarshalledValue mv = new MarshalledValue(namingProxy);
         if( trace )
            log.trace("Serialized Naming proxy, size="+mv.size());
         //response.setContentLength(mv.size());
         ServletOutputStream sos = response.getOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(sos);
         oos.writeObject(mv);
         oos.flush();
         oos.close();
      }
      catch(Throwable t)
      {
         log.debug("Invoke failed", t);
         // Marshall the exception
         response.resetBuffer();
         MarshalledValue mv = new MarshalledValue(t);
         ServletOutputStream sos = response.getOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(sos);
         oos.writeObject(mv);
         oos.close();
      }
View Full Code Here

      if (imageMimeType != null)
      {
        response.setHeader("Content-Type", imageMimeType);
      }
      response.setContentLength(imageData.length);
      ServletOutputStream ouputStream = response.getOutputStream();
      ouputStream.write(imageData, 0, imageData.length);
      ouputStream.flush();
      ouputStream.close();
    }
  }
View Full Code Here

        if (fbos.size() > 0)
        {
          response.setContentType("application/pdf");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
     
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType("application/pdf");

      JRPdfExporter exporter = new JRPdfExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

        if (fbos.size()> 0)
        {
          response.setContentType(getResponseContentType());
          setResponseHeader(response);
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();       
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType(getResponseContentType());
      setResponseHeader(response);

      JRXlsAbstractExporter exporter = getXlsExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
      exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

        if (fbos.size() > 0)
        {
          response.setContentType("application/vnd.oasis.opendocument.text");
  //        response.setHeader("Content-Disposition", "inline; filename=\"file.odt\"");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
     
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType("application/vnd.oasis.opendocument.text");
      //response.setHeader("Content-Disposition", "inline; filename=\"file.odt\"");

      JROdtExporter exporter = new JROdtExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        if (ouputStream != null)
        {
          try
          {
            ouputStream.close();
          }
          catch (IOException ex)
          {
          }
        }
View Full Code Here

TOP

Related Classes of javax.servlet.ServletOutputStream

Copyright © 2018 www.massapicom. 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.