You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are valid use-cases that may result in the sitemesh filter running twice (or more) in the context of a single request. One simple example of this involves using JSP pages to render HTML e-mail content. A request that dispatches such an e-mail can retrieve the rendered JSP contents as a string by including it (and wrapping the HttpServletResponse appropriately). Thus it can be desirable to have multiple runs of the sitemesh filter, one for the response that is ultimately sent to the client/browser, and one for each e-mail composed in this manner (because using sitemesh to decorate the e-mails would be extremely convenient).
I think there are a couple of simple ways to support this:
Make 'filterAlreadyAppliedForRequest' protected instead of private. Doing so will allow users to subclass SiteMeshFilter and provide their own implementation that can be made to run more than once per request as desired.
Instead of using the literal key of "com.opensymphony.sitemesh.APPLIED_ONCE" to flag whether or not the filter has been applied, suffix this key with something like the filter's hashCode or the current timestamp (or random number) at instantiation/init-time. That would allow a user who wants to have the filter applied twice in some scenarios to simply set up two instances of it with different filter-mappings (which can/will overlap in some cases). Neither filter would allow itself to be applied more than once per request, but both would be able to coexist side-by-side without one cancelling out the other.
The text was updated successfully, but these errors were encountered:
Whilst we are trying to remove SiteMesh from our webapps as and when we can, we ran into an issue where we forward a request, and the forward wouldn't go through SiteMesh because of the aforementioned APPLIED_ONCE flag, so we are just clearing that attribute before the forward to ensure the correct decorators are applied to the forwarded request's content.
You can't even exclude the request URL in decorators.xml because SiteMeshFilter sets APPLIED_ONCE to true before checking whether the request is excluded - these checks should be switched around:
if (filterAlreadyAppliedForRequest(request)) { ...}
if (!contentProcessor.handles(webAppContext)) { ... }
I guess we could create our own SiteMeshFilter impl if we really cared.
There are valid use-cases that may result in the sitemesh filter running twice (or more) in the context of a single request. One simple example of this involves using JSP pages to render HTML e-mail content. A request that dispatches such an e-mail can retrieve the rendered JSP contents as a string by including it (and wrapping the HttpServletResponse appropriately). Thus it can be desirable to have multiple runs of the sitemesh filter, one for the response that is ultimately sent to the client/browser, and one for each e-mail composed in this manner (because using sitemesh to decorate the e-mails would be extremely convenient).
I think there are a couple of simple ways to support this:
The text was updated successfully, but these errors were encountered: