Bug 37466 - c:import doesn't work with HEAD requests
Summary: c:import doesn't work with HEAD requests
Status: RESOLVED INVALID
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.2.1
Hardware: Other other
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on: 57601
Blocks:
  Show dependency tree
 
Reported: 2005-11-11 09:03 UTC by Eric Haszlakiewicz
Modified: 2015-03-02 14:55 UTC (History)
0 users



Attachments
A JSP file that will demonstrate the c:import problem. (576 bytes, application/octet-stream)
2005-11-11 09:05 UTC, Eric Haszlakiewicz
Details
XML data file to go along with testit.jsp. (30 bytes, text/xml)
2005-11-11 09:06 UTC, Eric Haszlakiewicz
Details
Unit test patch to taglibs test system for this bug. (4.00 KB, patch)
2007-01-04 17:28 UTC, Bjorn Townsend
Details | Diff
Patch to fix the issue. (1.88 KB, patch)
2007-01-10 14:08 UTC, Henri Yandell
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Haszlakiewicz 2005-11-11 09:03:45 UTC
Attempting to use c:import to read in a file results in no content if the
request sent the the web server is a HEAD instead of a GET.  This causes things
like parsing XML documents to fail, as well as anything else that might depend
on files being read correctly.
I'll attach an example jsp and xml file that demonstrates the problem.
Comment 1 Eric Haszlakiewicz 2005-11-11 09:05:38 UTC
Created attachment 16947 [details]
A JSP file that will demonstrate the c:import problem.
Comment 2 Eric Haszlakiewicz 2005-11-11 09:06:07 UTC
Created attachment 16948 [details]
XML data file to go along with testit.jsp.
Comment 3 Eric Haszlakiewicz 2005-11-11 09:11:38 UTC
To see the problem, copy testit.jsp and testit.xml to a webapp.  Then send a
HEAD request, perhaps like this:

> telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HEAD /mywebapp/testit.jsp HTTP/1.1
Host: localhost 8080

HTTP/1.1 500 Internal Server Error
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Date: Fri, 11 Nov 2005 08:07:55 GMT
Server: Apache-Coyote/1.1
Connection: close

Connection closed by foreign host.
>

The internal server error is due to x:parse complaining with:
org.xml.sax.SAXParseException: Premature end of file.
Comment 4 Eric Haszlakiewicz 2005-11-11 09:13:10 UTC
d'oh! cut'n'paste error.  The Host: line is missing a colon:
Host: localhost:8080
Comment 5 Bjorn Townsend 2007-01-04 17:28:30 UTC
Created attachment 19364 [details]
Unit test patch to taglibs test system for this bug.
Comment 6 Henri Yandell 2007-01-10 13:13:38 UTC
Problem occurs regardless of whether var=".." or varReader=".." is used in the
c:import.
Comment 7 Henri Yandell 2007-01-10 14:03:46 UTC
This issue was brought up on tomcat-dev by the original poster, and Bill Barker
suggests a JSTL fix:

http://mail-archives.apache.org/mod_mbox/tomcat-users/200512.mbox/%3cdo4qqm$eg4$1@sea.gmane.org%3e
Comment 8 Henri Yandell 2007-01-10 14:08:07 UTC
Created attachment 19388 [details]
Patch to fix the issue.
Comment 9 Henri Yandell 2007-01-10 14:09:39 UTC
svn ci -m "Applying Bjorn Townsend's unit test and the fix for #37466 - c:import
doesn't work with HEAD requests. Many thanks to Bill Barker on tomcat-dev for
providing the idea behind the fix. "

Sending        src/org/apache/taglibs/standard/tag/common/core/ImportSupport.java
Adding         test/org/apache/taglibs/standard/tag/ImportTagTest
Adding         test/org/apache/taglibs/standard/tag/ImportTagTest/core
Adding        
test/org/apache/taglibs/standard/tag/ImportTagTest/core/Test37466.java
Adding         test/web/org/apache/taglibs/standard/tag/ImportTagTest
Adding         test/web/org/apache/taglibs/standard/tag/ImportTagTest/core
Adding        
test/web/org/apache/taglibs/standard/tag/ImportTagTest/core/Test37466.jsp
Adding        
test/web/org/apache/taglibs/standard/tag/ImportTagTest/core/Test37466.xml
Transmitting file data ....
Committed revision 495005.
Comment 10 Jeremy Boynes 2015-02-18 16:14:39 UTC
The patch in r495005 attempts to address this by wrapping the HttpServletRequest and overriding the getMethod() call to always return GET.

The works on Tomcat when importing a static resource as it causes the DefaultServlet to return content (when the method is HEAD DefaultServlet always returns no content). However, it breaks other servlets that may rely on the method, for example, a servlet that overrides doPost().
Comment 11 Jeremy Boynes 2015-03-02 14:55:39 UTC
Reverted the fix in http://svn.apache.org/r1663321 to be included in Taglibs 1.2.4

The associated change to Tomcat means the patch that addressed this is no longer appropriate. Resolving as INVALID.