Code example for HttpResponse

Methods: containsHeader, getEntity, getFirstHeader

                                   HttpPost httppost, Writer out, HttpClient httpclient)
        throws ServletException, IOException, JSONException 
        // Get hold of the response entity 
        HttpEntity entity = authResponse.getEntity();
        StringBuffer authResponseData = new StringBuffer();
        // If the response does not enclose an entity, there is no need 
        // to worry about connection release 
        if (entity != null) {
            InputStream instream = entity.getContent();
            BufferedReader reader = null;
            try { 
                reader = new BufferedReader(new InputStreamReader(instream));
                // do something useful with the response 
            } catch (RuntimeException ex) {
                // In case of an unexpected exception you may want to abort 
                // the HTTP request in order to shut down the underlying 
                // connection and release it back to the connection manager. 
                LOGGER.throwing(AuthServlet.class.getName(), "doLogin", ex);
                throw ex;
            } finally { 
                // Closing the input stream will trigger connection release 
                if (reader != null) {
            // When HttpClient instance is no longer needed, 
            // shut down the connection manager to ensure 
            // immediate deallocation of all system resources 
        //Now we write the response back to our client. 
        if (authResponse.containsHeader("WWW-Authenticate")) {
             // If the authentication server responded with a 401 it means 
             // that the specified username and password weren't valid.  We 
             // should be returning a 401 to the client, but doing that causes 
             // Firefox to prompt for login using the default login dialog 
             // and we don't want that. 
            response.setHeader("WWW-Authenticate", authResponse.getFirstHeader("WWW-Authenticate").getValue());
        } else {