views:

24

answers:

1

Hi there.

I have a custom 404 error page in my java web app. (declared using web.xml) It is working in all the cases. But if the url pattern comes like for example : www.mysite.com/admin/cannotfind the custom error page doesnt locate the images and css java script files for 404 custom error page. But it get works for normal url like www.mysite.com/cannotfind. Anyone tell me why is this behavior.

this is my error page configuration

<error-page>
    <error-code>404</error-code>
    <location>/error_pages/error_404.jsp</location>

tx :)

+1  A: 

An error page is delivered under the URL of the page containing the error (using an internal forward request dispatching). So links relative to the error page will not work. You need server absolute links here (starting with /, prefixed by the context path, in JSP this is ${pageContext.request.contextPath}).

Or you can define a HTML base tag, but you will need the full URL (with host) of the error page.

Arne Burmeister
where to add ${pageContext.request.contextPath}
before the links off css and javascript (and images if linkes direct)
Arne Burmeister
thanks it worked. I didnt think about that. :)