1

Java I have situation where i have to fetch web contents of response in result of form submit, but it is little tricky b/s the flow is not as simple as request and response, is as follows.

Submit button pressed -> Display page processing wait timer -> Display quick advertisement page -> Display page result.

Starting from "submit button pressed" i want to have "Display page result" contents and skip pages in between.

I have this sample code but it works only in one way, send request and receive response.

URL url;
InputStream is = null;
DataInputStream dis;
String line;

try {
    url = new URL("http://stackoverflow.com/");
    is = url.openStream();  // throws an IOException
    dis = new DataInputStream(new BufferedInputStream(is));

    while ((line = dis.readLine()) != null) {
        System.out.println(line);
    }
} catch (MalformedURLException mue) {
     mue.printStackTrace();
} catch (IOException ioe) {
     ioe.printStackTrace();
} finally {
    try {
        is.close();
    } catch (IOException ioe) {
        // nothing to see here
    }
}

any java library can do it for me? Thanks in advance.

d-man
  • 57,473
  • 85
  • 212
  • 296

1 Answers1

1

Consider to give a try to Selenium web driver. May be it has what you are trying to implement.

0x41ndrea
  • 385
  • 5
  • 23
  • check if this post on [SO](http://stackoverflow.com/questions/11928813/how-can-i-ask-selenium-webdriver-to-wait-for-some-time) can help – 0x41ndrea Dec 27 '12 at 07:41
  • Page i am requesting it loads form using ajax on page onload, thats why using HtmlUnitDriver it does not found form elements ? any suggestion – d-man Dec 27 '12 at 14:31
  • i eabled the javascript to load ajax components but it is giving restrict url exception on facebook contents. – d-man Dec 27 '12 at 15:05