0

I am trying to create an Android App to display my school agenda.

I'm doing it fine at the beginning with loopj. I can connect to my school account and get pages. BUT, the agenda part is a JSP page and i'm entering into "onFailure" method.

I'm using the loopj asynchttp library. I Think it simply does not handle JSP.

Do you have any idea of how to get it ? Once i get it, the goal is to parse it with JSOUP and extract only the data i want to.

Here's my loopj snippet :

// try to get the planning
App_Web.client.get("the_url ...", null, new TextHttpResponseHandler() {

    @Override
    public void onFailure(int i, Header[] headers, String s, Throwable throwable) {
        System.out.println("FAILED");
    }

    @Override
    public void onSuccess(int i, Header[] headers, String s) {

        System.out.print("OK");

    }
});

I need to be connected before i reach the page.

So i do have to use the loopj session if you tell me to use an other library or use a library which can handle session.

Please tell me if you do not understand something i can maybe help you to understand better.

Cheers,

Maxime

Alkis Kalogeris
  • 17,044
  • 15
  • 59
  • 113
maxime1992
  • 22,502
  • 10
  • 80
  • 121

1 Answers1

1

JSP is an acronym of Java Server Pages. That's a java technology for righting dynamic web pages. The fact that you are trying to parse a page that was built using jsp should not concern you since that's relevant only on the server. You as a client, be it a web browser or an htmml parser as jsoup or loopj, are receiving pure html. No java/jsp code is on your end, since all the jsp was compiled and run and in the end produced the desired html that you get.

Now that we cleared that, back to your app. You can check the reason for the onFailure being called by printing the stacktrace of the Throwable argument you receive. Check the docs . As you can see, for the Throwable class you can call printStackTrace() to read the recorded steps that lead to the problem. Not having seen the stacktrace I can't really be of much help, but most likely is a timeout problem or a header problem. Check the stack and I'll try to help some more.

Alkis Kalogeris
  • 17,044
  • 15
  • 59
  • 113
  • thank you for your answer. I know jsp is relevant only on the server but i was struggling with this super complex page. In fact, most of the data were loaded in Ajax when document was ready. (More than 10 ajax requests to build the whole page, just awful). So the best thing i could do was to use phantomJS & casperJS (powerful btw !) to get the page, wait till the page get all the data, scrap it and send a json file on a server that my app is calling later. Thanks again :) ! – maxime1992 Sep 18 '14 at 22:30
  • No problem. I'm glad you figured out a way to accomplish your task. Please post your solution as an answer and accept it. – Alkis Kalogeris Dec 01 '14 at 10:49