"I thought to create a RuntimeException that will be thrown instead of the
AbortWithWebErrorCodeException(...) and to analyze it in the
onRuntimeException."

don't you gona fall in to the same problem this way?

Set error page in web.xml
   <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>


    <error-page>
        <error-code>
            403
        </error-code>
        <location>
            /403.*html*
        </location>
    </error-page>

</web-app>



On Thu, Sep 3, 2009 at 5:27 AM, Eyal Golan <[email protected]> wrote:

> Hello,
> We have in our application the following code:
>    /**
>     * @see
> org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
>     *      org.apache.wicket.Response)
>     */
>    @Override
>    public RequestCycle newRequestCycle(final Request request,
>            final Response response) {
>        return new WebRequestCycle(this, (WebRequest) request,
>                (WebResponse) response) {
>
>            @Override
>            public Page onRuntimeException(Page page, RuntimeException e) {
>                if (DEPLOYMENT.equalsIgnoreCase(getConfigurationType())) {
>                    if
> (PageExpiredException.class.isAssignableFrom(e.getClass())) {
>                        return null;
>                    } else {
>                        e.printStackTrace();
>                        System.out.println(e.getMessage());
>                        return new InternalErrorPage(getErrorDisplay(e));
>                    }
>                } else {
>                    // In development we want to see the exception
>                    return null;
>                }
>
>            }
>        };
>    }
>
> Also, in our base page we have this
>    protected void verifyAccess(PageParameters pageParameters) {
>        // Redirect to Login page on invalid access.
>        if (!isUserLoggedIn()) {
>            throw new RestartResponseAtInterceptPageException(Login.class);
>        }
>        else if (! isPageAllowed(pageParameters)) {
>            String url = pageParameters.getString("url");
>            if (url != null) {
>                throw new
> AbortWithWebErrorCodeException(HttpServletResponse.SC_FORBIDDEN, url);
>            }
>            else {
>                throw new
> AbortWithWebErrorCodeException(HttpServletResponse.SC_FORBIDDEN);
>            }
>        }
>    }
>
> 'verifyAccess' is called in the construction of the page.
>
> The problem I'm having is when the page is not allowed.
> We throw AbortWithWebErrorCodeException.
>
> The user gets a 403 error page.
> As expected, the onRuntimeException that configured in the WebApp is not
> reached.
>
> I thought to create a RuntimeException that will be thrown instead of the
> AbortWithWebErrorCodeException(...) and to analyze it in the
> onRuntimeException.
> But, is there a way to map the 403 error page to another page? A setting of
> the Application or even in the web.xml?
>
> Thanks,
>
>
>
> Eyal Golan
> [email protected]
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>
> P  Save a tree. Please don't print this e-mail unless it's really necessary
>

Reply via email to