[MAGNOLIA-1565] Allow error pages (401,404,500 etc,etc) to be configured as Magnolia pages Created: 31/May/07  Updated: 23/Jan/13  Resolved: 19/Aug/09

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: 3.5

Type: New Feature Priority: Minor
Reporter: zam6ak Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

3.1-SNAPSHOT
JBoss 4.0.5


Issue Links:
relation
is related to MAGNOLIA-3107 Custom error page not rendered (jsp t... Closed
is related to MAGNOLIA-2136 Public instance: different error page... Closed
Template:
Acceptance criteria:
Empty
Date of First Response:

 Description   

While discussing error page locations with Sameer (via dev list and support), it was suggested that this feature may make it into next version.

The goal would be to mimic web.xml error page logic where one can define an error code or exception (or both) and specify Magnolia page that should be displayed when such error/exception occurs.



 Comments   
Comment by Magnolia International [ 10/Sep/08 ]

Since 3.5, the ERROR dispatcher is assigned to the main Magnolia filter by default. If that's the case in your setup too, the 404 page in your web.xml needs to be reachable through Magnolia. Typically, you could have this in your web.xml:

 
  <error-page>
    <error-code>404</error-code>
    <location>/errors/404.html</location>
  </error-page>

.. and upon request of an unexisting resource, Magnolia would serve your /error/404 page.

Now, as far as I can tell, there is no other way than mapping all error codes in web.xml - we could do so by default, and a have location like /.magnolia/error which would take care, based on some configuration, render the configured page for the different codes, but

  • is it really worth it ? i.e how much configuration will one be ready to do when it can be done directly in web.xml ? - (if there was a way to map "all" error codes to locations, I'd love it but as far as i can tell you have to map each and every error code separately)
  • as far as I can tell, when serving an error page, you can't really know what the error code and message were (unless i've missed the obvious)

Any suggestion ?

Comment by Magnolia International [ 10/Sep/08 ]

This just in, the following request attributes are set when serving an error page:

  • when serving for a mapped error code:
        javax.servlet.error.message = NOT_FOUND
        javax.servlet.error.request_uri = /magnolia-empty-webapp/eee.html
        javax.servlet.error.servlet_name = default
        javax.servlet.error.status_code = 404
    
  • when serving for a mapped exception:
        javax.servlet.error.exception = java.lang.UnsupportedOperationException: my error message
        javax.servlet.error.exception_type = class java.lang.UnsupportedOperationException
        javax.servlet.error.message = my error message
        javax.servlet.error.request_uri = /magnolia-empty-webapp/docroot/test2.jsp
        javax.servlet.error.servlet_name = jsp
        javax.servlet.error.status_code = 500
    
Comment by Fabrizio Giustina [ 19/Aug/09 ]

Solved a long time ago, by mapping the magnolia filter with ERROR dispatcher like explained by Gregory

Generated at Mon Feb 12 03:28:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.