ClassCastException in webclient

Posted by narendra on Stack Overflow See other posts from Stack Overflow or by narendra
Published on 2012-06-22T17:56:30Z Indexed on 2012/07/01 9:16 UTC
Read the original article Hit count: 221

Filed under:
|

I am using web client for getting page source. First time i am getting page source. After i use the same object for getting page source for different URL it's showing an Exception like:

java.lang.ClassCastException: com.gargoylesoftware.htmlunit.UnexpectedPage cannot be cast to com.gargoylesoftware.htmlunit.html.HtmlPage

This is the code which i am using.

HtmlPage firstPage = webClient.getPage("firsturl");
HtmlPage downloadPage = null;
        try {
            webClient.setJavaScriptEnabled(true);

            downloadPage = (HtmlPage) webClient.getPage("secondurl");
        } catch (Exception e) {
            e.printStackTrace();
        }

Thx in advance

© Stack Overflow or respective owner

Related posts about java

Related posts about webclient