@Override
        public void onWritePossible() throws IOException {
            // This method may be invoked multiple times and by different threads, e.g. when writing large byte arrays.
            // Make sure a write/complete operation is only done, if no other write is pending, i.e. if isReady() == true
            // Otherwise WritePendingException is thrown.
            Log.trace("Data can be written to [{}]", remoteAddress);
            synchronized ( context )
            {
                final ServletOutputStream servletOutputStream = context.getResponse().getOutputStream();
                while ( servletOutputStream.isReady() )
                {
                    final byte[] buffer = new byte[8*1024];
                    final int len = data.read( buffer );
                    if ( len < 0 )
                    {
                        // EOF - all done!
                        context.complete();
                        return;
                    }

                    // This is an async write, will never block.
                    servletOutputStream.write( buffer, 0, len );

                    // When isReady() returns false for the next iteration, the
                    // interface contract guarantees that onWritePossible() will
                    // be called once a write is possible again.
                }
            }
        }
Servlet which handles requests to the HTTP binding service. It determines if there is currently
an {@link HttpSession} related to the connection or if one needs to be created and then passes it
off to the {@link HttpBindManager} for processing of the client request and formulating of the
response.

@author Alexander Wenckus
xmppserver/src/main/java/org/jivesoftware/openfire/http/HttpBindServlet.java