Package javax.servlet

Examples of javax.servlet.ServletOutputStream


  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
    HttpSession httpsession = request.getSession();
    response.setContentType("image/jpeg");
    ServletOutputStream servletoutputstream = response.getOutputStream();
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0L);
    BufferedImage bufferedimage = new BufferedImage(WIDTH, HEIGHT, 1);
    Graphics g = bufferedimage.getGraphics();
    char ac[] = generateCheckCode();
    drawBackground(g);
    drawRands(g, ac);
    g.dispose();
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    ImageIO.write(bufferedimage, "JPEG", bytearrayoutputstream);
    byte abyte0[] = bytearrayoutputstream.toByteArray();
    response.setContentLength(abyte0.length);
    servletoutputstream.write(abyte0);
    bytearrayoutputstream.close();
    servletoutputstream.close();
    httpsession.setAttribute("check_code", new String(ac));
  }
View Full Code Here


  @Test
  public void testResetBuffer() throws IOException {
    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.isCommitted()).thenReturn(false);
    ServletOutputStream out = mock(ServletOutputStream.class);
    when(response.getOutputStream()).thenReturn(out);
    GZIPResponseWrapper test = new GZIPResponseWrapper(response);

    ServletOutputStream servletOutput = test.getOutputStream();
    assertEquals(org.apache.hadoop.hbase.rest.filter.GZIPResponseStream.class,
        servletOutput.getClass());
    test.resetBuffer();
    verify(response).setHeader("Content-Encoding", null);

    when(response.isCommitted()).thenReturn(true);
    servletOutput = test.getOutputStream();
    assertEquals(out.getClass(), servletOutput.getClass());
    assertNotNull(test.getWriter());

  }
View Full Code Here

  @Test
  public void testReset() throws IOException {
    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.isCommitted()).thenReturn(false);
    ServletOutputStream out = mock(ServletOutputStream.class);
    when(response.getOutputStream()).thenReturn(out);
    GZIPResponseWrapper test = new GZIPResponseWrapper(response);

    ServletOutputStream servletOutput = test.getOutputStream();
    assertEquals(org.apache.hadoop.hbase.rest.filter.GZIPResponseStream.class,
        servletOutput.getClass());
    test.reset();
    verify(response).setHeader("Content-Encoding", null);

    when(response.isCommitted()).thenReturn(true);
    servletOutput = test.getOutputStream();
    assertEquals(out.getClass(), servletOutput.getClass());
  }
View Full Code Here

  }

  @Test
  public void testGZIPResponseStream() throws IOException {
    HttpServletResponse httpResponce = mock(HttpServletResponse.class);
    ServletOutputStream out = mock(ServletOutputStream.class);

    when(httpResponce.getOutputStream()).thenReturn(out);
    GZIPResponseStream test = new GZIPResponseStream(httpResponce);
    verify(httpResponce).addHeader("Content-Encoding", "gzip");
View Full Code Here

            boolean useOutputStreamNotWriter = false;
            if (this.servletContext != null) {
                useOutputStreamNotWriter = UtilJ2eeCompat.useOutputStreamNotWriter(this.servletContext);
            }
            if (useOutputStreamNotWriter) {
                ServletOutputStream ros = response.getOutputStream();
                writer = new OutputStreamWriter(ros, UtilProperties.getPropertyValue("widget", getName() + ".default.contenttype", "UTF-8"));
            } else {
                writer = response.getWriter();
            }
View Full Code Here

            res.setStatus(404);
        }
        if (debug >= 10) {

            ServletOutputStream out = res.getOutputStream();
            out.println("<HTML><HEAD><TITLE>$Name$</TITLE></HEAD>");
            out.println("<BODY>$Header$<p>");

            if (cgiEnv.isValid()) {
                out.println(cgiEnv.toString());
            } else {
                out.println("<H3>");
                out.println("CGI script not found or not specified.");
                out.println("</H3>");
                out.println("<H4>");
                out.println("Check the <b>HttpServletRequest ");
                out.println("<a href=\"#pathInfo\">pathInfo</a></b> ");
                out.println("property to see if it is what you meant ");
                out.println("it to be.  You must specify an existant ");
                out.println("and executable file as part of the ");
                out.println("path-info.");
                out.println("</H4>");
                out.println("<H4>");
                out.println("For a good discussion of how CGI scripts ");
                out.println("work and what their environment variables ");
                out.println("mean, please visit the <a ");
                out.println("href=\"http://cgi-spec.golux.com\">CGI ");
                out.println("Specification page</a>.");
                out.println("</H4>");

            }

            printServletEnvironment(out, req, res);

            out.println("</BODY></HTML>");

        }


    } //doGet
View Full Code Here

    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

        ServletOutputStream os = response.getOutputStream();

        os.println();
        os.println("/* Apache Tuscany - SCA Web Widget */");
        os.println();

        writeSCAWidgetCode(os, request.getServletPath());
    }
View Full Code Here

    status = HttpServletResponse.SC_OK;
    characterEncoding = "UTF-8";
    locale = null;

    byteStream = new ByteArrayOutputStream();
    servletStream = new ServletOutputStream()
    {
      @Override
      public void write(int b)
      {
        byteStream.write(b);
View Full Code Here

                content = false;
            }

        }

        ServletOutputStream ostream = null;
        PrintWriter writer = null;

        if (content) {

            // Trying to retrieve the servlet output stream
View Full Code Here

            isStreamUsed = true;
            if (bos == null)
            {
                bos = new ByteArrayOutputStream();
            }
            ServletOutputStream sos = new ServletOutputStream()
                {
                    public void write(int b) throws IOException
                    {
                        bos.write(b);
                    }
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.