开发者

getting HTTPResponse entity

I am trying to fetch the html code from the response after executing get method on the server and my code just stops when i try to parse the entity. And the execution just stops on the line "String loginResponseBody = EntityUtils.toString(response .getEntity());"

what does it mean and are there anyother methods of doing so?

HttpResponse response = client.httpPost1(viewState,
                            "http://syspower.skm.no/syspower3/mobile/Login.aspx",
                            username, password);
                    System.out.println("got response");
                    System.out.println(response);

                    System.out.println(response.getStatusLine());

                    String loginResponseBody = EntityUtils.toString(response
                            .getEntity());
                    System.out.println(loginResponseBody);

                    String table = clearHTML(loginResponseBody);


System.out.println(table);

P.S. entity is not null and the same portion of code works in other parts of app

P.P.S. that is my fault totally, start not to understand my own code.. I was supposed to get reply after I execute GET function on the s开发者_运维知识库erver, because after post i was getting redirect all the time(by server). So the final version is like:

String viewState = client
                        .httpGetViewstate("http://syspower.skm.no/syspower3/mobile/Login.aspx");

                HttpResponse response = client.httpPost1(viewState,
                        "http://syspower.skm.no/syspower3/mobile/Login.aspx",
                        userPrefs.getUserName(), userPrefs.getUserPassword());
                System.out.println("posted!");

                String commentsHtml = client
                        .httpGet("http://syspower.skm.no/syspower3/mobile/PriceTables.aspx");

                // System.out.println(commentsHtml);

                if (commentsHtml.contains("table")) { //or better to do with the Jsoup to search for first table
                    success = true;
                    System.out.println("username is ok");

                    System.out.println(commentsHtml);

                    this.finish();
                } else {
                    System.out.println("back again..");
                    fail = true;
                    loginBox();
                }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜