private void showAccounts(String instanceUrl, String accessToken,
            PrintWriter writer) throws ServletException, IOException {
        HttpClient httpclient = new HttpClient();
        GetMethod get = new GetMethod(instanceUrl
                + "/services/data/v20.0/query");

        // set the token in the header
        get.setRequestHeader("Authorization", "OAuth " + accessToken);

        // set the SOQL as a query param
        NameValuePair[] params = new NameValuePair[1];

        params[0] = new NameValuePair("q",
                "SELECT Name, Id from Account LIMIT 100");
        get.setQueryString(params);

        try {
            httpclient.executeMethod(get);
            if (get.getStatusCode() == HttpStatus.SC_OK) {
                // Now lets use the standard java json classes to work with the
                // results
                try {
                    JSONObject response = new JSONObject(
                            new JSONTokener(new InputStreamReader(
                            get.getResponseBodyAsStream())));
                    System.out.println("Query response: "
                            + response.toString(2));

//					writer.write(response.getString("totalSize")
                    writer.write(response.getInt("totalSize")
                            + " record(s) returned\n\n");

                    JSONArray results = response.getJSONArray("records");

                    for (int i = 0; i < results.length(); i++) {
                        writer.write(results.getJSONObject(i).getString("Id")
                                + ", "
                                + results.getJSONObject(i).getString("Name")
                                + "\n");
                    }
                    writer.write("\n");
                } catch (JSONException e) {
                    throw new ServletException(e);
                }
            }
        } finally {
            get.releaseConnection();
        }
    }