Results 1 to 6 of 6
  1. #1
    Eviler is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default Read URL with delay

    Hello,

    my problem seems quite simple, but I have not yet found a suitable solution.
    My problem is the following:

    I need to log in to a secure website and retrieve a bit of information.

    So far, logging in and going to the secure website is no problem and I get the html off it, but there is a problem. The site needs a minute to load my personal data and displays a "please while while your data is loaded" message. This is the one I get the html from.

    My question to you is: How would I tell the program to go to an URL, wait 60 seconds before reading it and only then read it, thus successfully skipping the "loading data" message.

    Any help is appreciated, example is appreciated too.

    My current code:

    Java Code:
    //opening login site + adding data
    
    ...
    
    //actually site I need
    URL url2 = new URL("https://www.telenet.be/mijntelenet/telemeter/showUsage.do?identifier=w590990");
    
    HttpURLConnection conn2 = (HttpURLConnection) url2.openConnection();
    conn2.setRequestMethod("GET");
    conn2.setDoInput(true);
    conn2.setDoOutput(true);
    writeCookies(conn2, true); //simply writes the login cookie I received to prove I'm logged in
    
    conn2.connect();
    
    BufferedReader in2 = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
    line = null;
    while ((line = in2.readLine()) != null) {
         System.out.println(line);
    }
    in2.close();

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Thread.sleep(...)? java.util.Timer?

    db

  3. #3
    Eviler is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    I've tried those already, same for setTimeout(), wait() and such

    The problem seems so simple, yet it's been bugging me for days now ...

  4. #4
    Ray Newman is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Try using the BufferedReader.ready() method to determine if the stream is ready to be read before reading, if not, then Thread.sleep(1000), then try again. Once it's ready, read it.
    Ray

  5. #5
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    I suggest determining how the message and results are being displayed, which will let you know how to tackle the problem. Redirect (relatively simple)? Javascript (not so simple)? If javascript, you can wait however you wish, but the problem with updates from javascript lies in the fact that you can read the page any which way you want, without taking into account the scripting you will get the same answer.
    Last edited by doWhile; 04-04-2011 at 02:58 AM.

  6. #6
    Eviler is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Hey,

    I think it's through javascript then. It probably gets my information from their database and then update the page with that information.

    How can I take the javascript into account?

Similar Threads

  1. Struts menu items delay
    By seol_sensei in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 05-31-2011, 01:20 AM
  2. Quick question about for looping and delay
    By DouboC@gmail.com in forum JDBC
    Replies: 0
    Last Post: 12-29-2010, 09:00 PM
  3. Animation Delay - Thread problem
    By wererabit in forum Advanced Java
    Replies: 3
    Last Post: 04-10-2009, 10:35 PM
  4. how to give delay?
    By shaluchandran in forum New To Java
    Replies: 10
    Last Post: 12-17-2008, 05:57 PM
  5. Delay on inputs during calculation
    By matt_well in forum New To Java
    Replies: 14
    Last Post: 07-26-2008, 04:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •