[BLOSSOM-91] Blossom request wrapper problem Created: 01/Jun/12  Updated: 07/Nov/14  Resolved: 20/Jul/12

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Jan Christian Haddorp Assignee: Tobias Mattsson
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 4.4.8 + Tomcat 6


Template:
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   

Inside a Blossom paragraph we set a variable on request scope.
<c:set var="name" value="value" scope="request" />

At the end of the main template (not Blossom) we try to retrieve the value; but it is null.
Doing the same with a normal Magnolia - everything works fine!

It seems Blossom wraps the original request into info.magnolia.module.blossom.support.IncludeRequestWrapper.
Request attributes added to this wrapped request seem not being populated into the original request.

As using Tomcat 6 our original request is org.apache.catalina.core.ApplicationHttpRequest.
I'm quite sure that the same code has been working fine with a former Magnolia / Blossom release.
Doing the same with session scope also works fine. Must be definitively something regarding the request.



 Comments   
Comment by Tobias Mattsson [ 01/Jun/12 ]

The Spring DispatcherServlet cleans up any request attributes set within an include request by default. Its done intentionally to prevent side effects from model attributes clashing.

The feature can be turned off, do that in your module class when creating the BlossomDispatcherServlet.

Snippet from DispatcherServlet.java:

	/**
	 * Set whether to perform cleanup of request attributes after an include request, that is,
	 * whether to reset the original state of all request attributes after the DispatcherServlet
	 * has processed within an include request. Otherwise, just the DispatcherServlet's own
	 * request attributes will be reset, but not model attributes for JSPs or special attributes
	 * set by views (for example, JSTL's).
	 * <p>Default is "true", which is strongly recommended. Views should not rely on request attributes
	 * having been set by (dynamic) includes. This allows JSP views rendered by an included controller
	 * to use any model attributes, even with the same names as in the main JSP, without causing side
	 * effects. Only turn this off for special needs, for example to deliberately allow main JSPs to
	 * access attributes from JSP views rendered by an included controller.
	 */
	public void setCleanupAfterInclude(boolean cleanupAfterInclude) {
		this.cleanupAfterInclude = cleanupAfterInclude;
	}
Generated at Sun Feb 11 23:30:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.