Catch Server 503 Error - Or Catch Stale Page

asked 2013-04-17 16:01:55 +0800

ansancle gravatar image ansancle
327 9

updated 2013-04-18 12:36:47 +0800

Does anyone know how to catch the server 503 error thrown by the browser if the server has gone down?

Or another way to put this is catch a stale page, the server has cycled and is back up but our page is now stale.

In my case, if we are sitting on a page and the server is restarted, the next time the user presses anything it will pop the "503: Service Temporarily Unavailable" dialog, then when they hit ok the page will reload and all is well. I want to do that reload under the covers so the dialog never gets popped.

I haven't found anything on the web and was wondering if anyone knows a ZK way or any other way to do this. Thanks! Andy

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted

answered 2013-06-28 08:20:32 +0800

benbai gravatar image benbai
2228 6

You can specify reload-uri with respect to specific response code under error-reload element of client-config element in zk.xml, please refer to the sample below (also include error handling and session timeout)


    <!-- for response error, e.g., 500, 503 -->
    <!-- for Exception throwed in Event Listener -->
    <!-- for session timeout -->


    Test steps:
    <div />
    1. click 'response 503' button
    <div />
    2. click 'throw exception' button
    <div />
    3. Restart server then click 'test session timeout' button
    <div />
    <button label="response 503" onClick="alert(123);">
        <attribute name="onClick"><![CDATA[
    <button label="throw exception">
        <attribute name="onCreate"><![CDATA[
            import org.zkoss.zk.ui.event.EventListener;
            import org.zkoss.zk.ui.event.Event;
            import org.zkoss.zk.ui.event.Events;
            self.addEventListener(Events.ON_CLICK, new EventListener () {
                public void onEvent (Event event) {
                    throw new Exception("");
    <button label="test session timeout" onClick="alert(123);" />
    <div />
    loaded time: <label onCreate='self.setValue(System.currentTimeMillis() + "")' />

refresh.zul (for error handling)



The client-config Element

The error-reload Element

The error-page Element

Error Handling

Session Timeout Management

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-04-17 16:01:55 +0800

Seen: 18 times

Last updated: Jun 28 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More