[MAGNOLIA-3107] Custom error page not rendered (jsp templates) Created: 05/Mar/10  Updated: 23/Jan/13  Resolved: 07/Mar/10

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 4.0.3, 4.1.4, 4.2.3, 4.3
Fix Version/s: 4.3

Type: Bug Priority: Major
Reporter: Diego Schivo Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File JspTemplateRenderer.patch    
Issue Links:
relation
is related to MAGNOLIA-1565 Allow error pages (401,404,500 etc,et... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

The problem occurs when an exception (eg: NullPointerException) is thrown during the rendering of a page with jsp template: if a custom error page (also with jsp template) has been configured in web.xml, it does not display (blank page instead).

Example of web.xml configuration:

<error-page>
  <exception-type>java.lang.Throwable</exception-type>
  <location>/myapp/errors/error.html</location>
</error-page>

The MgnlMainFilter receives the request for the error page, but immediatly bypasses it, due to voter "dontDispatchOnForwardAttribute":

2010-03-04 10:57:32,437 DEBUG info.magnolia.cms.filters.MgnlMainFilter MgnlMainFilter.java(doFilter:93) Handling URI: /myapp/errors/error.html - Path info: null
2010-03-04 10:57:32,437 DEBUG info.magnolia.voting.DefaultVoting DefaultVoting.java(vote:58) voter [dontDispatchOnForwardAttribute: ] fired 1
2010-03-04 10:57:32,437 DEBUG info.magnolia.voting.DefaultVoting DefaultVoting.java(vote:62) highest vote is now 1

I found that the dontDispatchOnForwardAttribute voter prevents the rendering of the error page because just before starting the rendering of the original page (the one that throws the Exception) an attribute DONT_DISPATCH_ON_FORWARD_ATTRIBUTE was put in request by the JspTemplateRenderer:

// set this attribute to avoid a second dispatching of the filters
request.setAttribute(DontDispatchOnForwardAttributeVoter.DONT_DISPATCH_ON_FORWARD_ATTRIBUTE, Boolean.TRUE);

JspTemplateRenderer should remove that attribute when catching the exception: this would fix the problem.
See attached patch: JspTemplateRenderer.patch



 Comments   
Comment by Fabrizio Giustina [ 07/Mar/10 ]

removal of DONT_DISPATCH_ON_FORWARD_ATTRIBUTE in renderer added for 4.3 (m3)

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