Examples of ServletInputStream


Examples of javax.servlet.ServletInputStream

            try {
                int max = getContentLength();
                int len = 0;
                byte buf[] = new byte[getContentLength()];
                ServletInputStream is = getInputStream();
                while (len < max) {
                    int next = is.read(buf, len, max - len);
                    if (next < 0 ) {
                        break;
                    }
                    len += next;
                }
                is.close();
                if (len < max) {
                    // FIX ME, mod_jk when sending an HTTP POST will sometimes
                    // have an actual content length received < content length.
                    // Checking for a read of -1 above prevents this code from
                    // going into an infinite loop.  But the bug must be in mod_jk.
View Full Code Here

Examples of javax.servlet.ServletInputStream

    /**
     * @see javax.servlet.ServletRequest#getInputStream()
     */
    public ServletInputStream getInputStream() throws IOException {
        ServletInputStream sis = new MyServletInputStream(m_requestData, readLimit);
        return sis;
    }
View Full Code Here

Examples of javax.servlet.ServletInputStream

     * protected method to get a job in JsonBean representation
     */
    @Override
    protected JsonBean getJob(HttpServletRequest request, HttpServletResponse response) throws XServletException,
            IOException, BaseEngineException {
        ServletInputStream is = request.getInputStream();
        byte[] b = new byte[101];
        while (is.readLine(b, 0, 100) != -1) {
            XLog.getLog(getClass()).warn("Printing :" + new String(b));
        }

        JsonBean jobBean = null;
        String jobId = getResourceName(request);
View Full Code Here

Examples of javax.servlet.ServletInputStream

     */
    protected void uploadWar(HttpServletRequest request, File war)
        throws IOException {

        war.delete();
        ServletInputStream istream = null;
        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            byte buffer[] = new byte[1024];
            while (true) {
                int n = istream.read(buffer);
                if (n < 0) {
                    break;
                }
                ostream.write(buffer, 0, n);
            }
            ostream.flush();
            ostream.close();
            ostream = null;
            istream.close();
            istream = null;
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
            if (ostream != null) {
                try {
                    ostream.close();
                } catch (Throwable t) {
                    ;
                }
                ostream = null;
            }
            if (istream != null) {
                try {
                    istream.close();
                } catch (Throwable t) {
                    ;
                }
                istream = null;
            }
View Full Code Here

Examples of javax.servlet.ServletInputStream

    byte[] request = buildRequest();

    // Ok lets make an input stream to return
    final ByteArrayInputStream bais = new ByteArrayInputStream(request);

    return new ServletInputStream()
    {
      @Override
      public int read()
      {
        return bais.read();
View Full Code Here

Examples of javax.servlet.ServletInputStream

            byte[] request = buildRequest();

            // Ok lets make an input stream to return
            final ByteArrayInputStream bais = new ByteArrayInputStream(request);

            return new ServletInputStream() {

                public int read() {
                    return bais.read();
                }
            };
        } else {
            return new ServletInputStream() {

                public int read() {
                    return -1;
                }
            };
View Full Code Here

Examples of javax.servlet.ServletInputStream

      bodyAccessed = true;
      return reader;
    }
   
    public ServletInputStream getInputStream() throws IOException {
      ServletInputStream stream = getHttpServletRequest().getInputStream();
      bodyAccessed = true;
      return stream;
    }
View Full Code Here

Examples of javax.servlet.ServletInputStream

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        StringBuffer buf = null;
        if(request.getContentLength() > 0) {
            buf = new StringBuffer();
            ServletInputStream in = request.getInputStream();
            int i = 0;
            while(i<request.getContentLength()) {
                int c = in.read();
                if(c == -1) {
                    break;
                } else {
                    buf.append((char)c);
                }
            }
        } else if("chunked".equalsIgnoreCase(request.getHeader("Transfer-Encoding"))) {
           buf = new StringBuffer();
           ServletInputStream in = request.getInputStream();
           for(int c = in.read(); c != -1; c = in.read()) {
               if(c == -1) {
                   break;
               } else {
                   buf.append((char)c);
               }
View Full Code Here

Examples of javax.servlet.ServletInputStream

     */
    protected void uploadWar(HttpServletRequest request, File war)
        throws IOException {

        war.delete();
        ServletInputStream istream = null;
        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            byte buffer[] = new byte[1024];
            while (true) {
                int n = istream.read(buffer);
                if (n < 0) {
                    break;
                }
                ostream.write(buffer, 0, n);
            }
            ostream.flush();
            ostream.close();
            ostream = null;
            istream.close();
            istream = null;
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
            if (ostream != null) {
                try {
                    ostream.close();
                } catch (Throwable t) {
                    ;
                }
                ostream = null;
            }
            if (istream != null) {
                try {
                    istream.close();
                } catch (Throwable t) {
                    ;
                }
                istream = null;
            }
View Full Code Here

Examples of javax.servlet.ServletInputStream

     */
    protected void uploadWar(HttpServletRequest request, File war)
        throws IOException {

        war.delete();
        ServletInputStream istream = null;
        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            byte buffer[] = new byte[1024];
            while (true) {
                int n = istream.read(buffer);
                if (n < 0) {
                    break;
                }
                ostream.write(buffer, 0, n);
            }
            ostream.flush();
            ostream.close();
            ostream = null;
            istream.close();
            istream = null;
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
            if (ostream != null) {
                try {
                    ostream.close();
                } catch (Throwable t) {
                    ;
                }
                ostream = null;
            }
            if (istream != null) {
                try {
                    istream.close();
                } catch (Throwable t) {
                    ;
                }
                istream = null;
            }
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.