jamesfredley commented on PR #15541:
URL: https://github.com/apache/grails-core/pull/15541#issuecomment-4200812375

   ## JSP Layout Rendering Fix - `ca0ac3270f`
   
   The JSP `GrailsLayoutSpec."jsp demo"` test now passes. All 38 integration 
tests in the spec pass, and the full core build is green.
   
   ### Root Cause
   
   Tomcat 11 (Jakarta Servlet 6.1) calls `finish()` on the underlying response 
after `RequestDispatcher.forward()` completes. This commits the real servlet 
response. When the Grails layout decorator (`SpringMVCViewDecorator`) 
subsequently checks `response.isCommitted()` at line 70, it returns `true` and 
skips rendering the decorated layout - resulting in an empty page.
   
   The JSP content WAS being captured correctly into the Grails buffer (292 
chars), but the decorated output could never be written back to the response 
because Tomcat had already committed it.
   
   ### Fix
   
   Two changes in the `grails-layout` module:
   
   **`GrailsContentBufferingResponse.isCommitted()`** - Always returns `true`. 
This forces Spring's `InternalResourceView` to use `include()` instead of 
`forward()` for JSP dispatch. `include()` does not trigger Tomcat's response 
`finish()`, so the original response stays uncommitted and the layout decorator 
can write. This is safe because `GrailsContentBufferingResponse` is only used 
inside `EmbeddedGrailsLayoutView.obtainContent()` for content capture and is 
discarded after.
   
   **`GrailsPageResponseWrapper.reset()` / `resetBuffer()`** - Prevent Tomcat 
from clearing the content type activation state or the internal Grails content 
buffer during dispatch processing. When `parseablePage` is active, these calls 
are intercepted instead of delegating to the underlying container response.
   
   ### Verification
   
   - `GrailsLayoutSpec` - all 7 tests pass (including `"jsp demo"`)
   - `GspTagLibSpec` - all 14 tests pass  
   - `EndToEndSpec` - all 17 tests pass
   - Full core build with tests - BUILD SUCCESSFUL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to