I've implemented a custom 404 Page Not Found page for my web application
based in Wicket 1.5 following the Wicket wiki
(https://cwiki.apache.org/WICKET/error-pages-and-feedback-messages.html). I
tried to follow the tutorial as good as possible but it seems to be based on
a Wicket version before 1.5, so there seem to be some changes. 

As the HybridUrlCodingStrategy class doesn't exist any more I mounted the
page using this line of code. 

/mountPage("/404", PageNotFoundPage.class);/

The *configureResponse()* method of the PageNotFoundPage class looks like
this. 

/@Override
        protected void configureResponse(WebResponse response) {
                super.configureResponse(response);
                HttpServletResponse servletResp = (HttpServletResponse)
response.getContainerResponse();
                servletResp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}/

*The entry in the web.xml:*

/<filter-mapping>
    <filter-name>wicket.web</filter-name>
    <url-pattern>/web/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet-mapping>
    <servlet-name>jersey</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>
        
<error-page>
    <error-code>404</error-code>
    <location>/web/404</location>
</error-page>
/

My application is normally accessible under the following url.
http://localhost:8080/application/web/store where "store" is a mapping to
the home page of the application. 

Now when I browse http://localhost:8080/application/web/404 the
PageNotFoundPage page is displayed as expected and everything seems to be
all right. But when I try to provoke a real 404 error by browsing an URL
(e.g. http://localhost:8080/application/web/thispagedoesntexist) which
doesn't exist something odd happens. 

I would expect some kind of redirect to the 404 error page but the URL in
the browser stays the same and the browser shows the 404 PageNotFoundPage
page with the correct title, text and so one. So the error seems to be
recognized and handled by Wicket but the whole layout of the page is
missing. Inspecting the HTML of the page shows me there are some issues with
the URLs and that's why the browser cannot load all the resources like css,
images and so on. 

E.g. when calling the 404 page manually (not by provoking an error) the path
to the css file in the HTML is "../STYLE/style.css" which is translated to
by the browser to following absolute URL:
"http://localhost/application/STYLE/style.css";

Now when provoking an 404 error the path to the css file in the HTML is
"../../../../STYLE/style.css" which is translated by the browser to
"http://localhost/STYLE/style.css"; what of course is wrong. 

So at the moment I'm a little bit lost how to solve this issue. The 404 page
seems to work, also handling the error seems but both together doesn't.

Any suggestions what to do?


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Custom-404-page-is-not-displayed-correctly-tp4040091p4040091.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to