ClassCastException in webclient
- by narendra
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