Bug 57601

Summary: DefaultServlet returns no content when included during a HEAD request
Product: Tomcat 8 Reporter: Jeremy Boynes <jboynes>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P5    
Version: 8.0.x-trunk   
Target Milestone: ----   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 37466, 57602    
Attachments: Patch with test case and possible fix

Description Jeremy Boynes 2015-02-19 07:57:32 UTC
During a HEAD request, when a RequestDispatcher include is handled by the DefaultServlet the content of the static resource is not written to the HttpServletResponse. If the including servlet has wrapped the response before performing the include it will not receive the content of the resource.

This causes an issue for the JSTL <c:import> tag when a relative url is used in order to retrieve the resource, for example for use with the <x:parse> tag. Bug 37466 describes this case.

It is also a problem for other requests where the response headers may be affected by this lack of content causing different header values to be returned for GET vs. HEAD methods. For example, the Content-Length header does not account for bytes that are emitted by the included resource.
Comment 1 Jeremy Boynes 2015-02-19 08:05:24 UTC
Created attachment 32497 [details]
Patch with test case and possible fix

Patch that adds a test cases checking the Content-Length for GET and HEAD requests to a JSP page that includes a static resource.

Possible fix by checking the DispatcherType in DefaultServlet#doHead()
Comment 2 Mark Thomas 2015-03-02 11:44:46 UTC
Fixed in trunk, 8.0.x for 8.0.21 onwards and in 7.0.x for 7.0.60 onwards.