2 Replies Latest reply on Dec 21, 2008 7:30 PM by Michael Wohlfart

    handling 404 with error-page in web.xml

    Stefan S Newbie


      i was asked to make a custom page for handling http errors (403,404,...) and am facing a rather strange problem at the moment. displaying my own seam page by configuring an error-page in web.xml works like a charm. but unfortunately a path issue arises which is screwing with the included graphics and stylesheets.

      if the 404 error is raised while the url points at the same level in the web application path where the error page is located everything works fine. but as soon the two paths diverge the page is displayed correctly, but all the relative paths on the page get screwed up.

      for example when accessing a non existing resource servlet (e.g. contextRoot/seam/resource/nonexistingresource) the following situation arises:

      my error.seam page is displayed (including the text from the message.properties but the browser is looking for the stylesheet in the path contextRoot/seam/resource/nonexistingresource/style/layout.css - the same happens with all the graphics (linked in via h:graphicImage)

      any idea why this is happening, or more importantly how i could fix this
      thank you in advance!

        • 1. Re: handling 404 with error-page in web.xml
          Michael Wohlfart Expert


          I also configured web.xml for a custom error page and use

          <link rel="stylesheet" type="text/css" href="#{request.contextPath}/stylesheet/reset.css" media="screen" />

          to include my stylesheet which seems to work for me, maybe


          instead of


          is the right way to do this :-/

          however i would like to use

          <a4j:loadStyle src="resource:///stylesheet/reset.css"/>

          to include my stylesheets but the a4j tags don't work in my
          error page, can anyone shed some light on this, has anyone used the a4j:loadStyle tag in custom error pages?


          • 2. Re: handling 404 with error-page in web.xml
            Michael Wohlfart Expert

            sorry for the noise,

            was my bad, I had an incomplete filter-mapping in web.xml
            missing the dispatcher tags:

              <filter-name>Seam Filter</filter-name>