tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tennessee Leeuwenburg <>
Subject Handling HEAD request in servlet
Date Fri, 07 Jan 2005 00:48:48 GMT
Hi guys,

I have a problem where the default implementation of HttpServlet doesn't 
seem to be handling doHead(request, response) properly. I over-rode the 
method, and found the damndest thing happening. The line 
"response.setContentLength(length)" is just getting completely ignored. 
I can't work it out - it's like the response object is deliberately 
preventing me from setting the content-length. I tried 
setHeader("Content-Length", length) just in case but still no joy.

Note - this is a repost - the tomcat-dev people said I should post here, 
despite this relating to development issues rather than install or 
deployment problems, so please don't shoot me! I worked around the 
problem by using out.println("Content-Length: length") instead, but it's 
still bad that setContentLength() doesn't work, I think.

Help!? Please!

Here's the code snippet :

               FileInputStream inStream = null;
                     inStream = new FileInputStream(ncFile);
               int length = (int)ncFile.length();
               response.setHeader("Accept-Ranges", "bytes");
               response.setHeader("Impossible", "" + length);

Here's what I get back via telnet :

HTTP/1.1 206 Partial Content
Date: Thu, 06 Jan 2005 05:07:22 GMT
Server: Apache/2.0.50 (Ubuntu) mod_jk2/2.0.4
Set-Cookie: JSESSIONID=3D6C4C6EBE1AB1672E40C2933243BA3B; Path=/marslet
Accept-Ranges: bytes
Content-Length-Mimic: 36903060
Impossible: 36903060
Content-Type: application/x-netcdf
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message