This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
3 Replies Last post: Feb 8, 2010 2:37 PM by Vladimir Ikryanov  
  5 posts since
Aug 14, 2008
Currently Being Moderated

Sep 17, 2008 6:34 AM

How to get Http status Code?

 

I want to get the http status code , such as 202,404,302 .....

 

 

if  it is 202 I will getContent,if 404 I will notify other components error. 3XX  notify redirect.

 

 

How t o get the static code  By Browser API?

 

 

thanks a lot

 

 

 

 

Vladimir Ikryanov TeamDev Ltd. 1,013 posts since
Apr 24, 2006
Currently Being Moderated
1. Sep 17, 2008 12:51 PM in response to: calvin
Re: How to get Http status Code?

Hello,

 

JExplorer allows receiving status code only when an error has occurred during loading web page.

 


browser.setEventHandler(new DefaultWebBrowserEventsHandler() {
    public boolean navigationErrorOccured(WebBrowser webBrowser, String url, String frame, StatusCode statusCode)
    {
        showMessageSwingLoop("Navigation error: " + statusCode);

        return super.navigationErrorOccured(webBrowser, url, frame, statusCode);
    }
});

Regards,

Vladimir Ikryanov

yishai   27 posts since
Feb 13, 2007
Currently Being Moderated
2. Feb 8, 2010 7:52 AM in response to: Vladimir Ikryanov
Re: How to get Http status Code?

Hi

 

What will be the way with jxBrowser 2.0? Doesn't seem  to have the setEventHandler method?

 

BTW, not only for 404 codes but also for script errors on page?

 

Thanks

 

-Yishai

Vladimir Ikryanov TeamDev Ltd. 1,013 posts since
Apr 24, 2006
Currently Being Moderated
3. Feb 8, 2010 2:37 PM in response to: yishai
Re: How to get Http status Code?

Hi Yishai,


To handle JavaScript errors in JxBrowser you can use the following way:

BrowserServices browserServices = BrowserServices.getInstance();
browserServices.setPromptService(new DefaultPromptService() {
    @Override
    public CloseStatus scriptErrorRequested(ScriptErrorParams params) {
        System.out.println("params.getMessage() = " + params.getMessage());
        return super.scriptErrorRequested(params);
    }
});
 

As for the navigation error handling. We have not implemented such ability in JxBrowser yet. We will add it in JxBrowser 2.2 version.


Regards,

Vladimir Ikryanov

More Like This

  • Retrieving data ...