JSP and JSTL Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 3.09, 2006

Controlling HTTP Response Header Lines

Part:   1  2  3  4  5  6  7 

JSP/JSTL Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

Using Cookies

Using JavaBean Classes

HTTP Response Header Lines

Non ASCII Characters

JSTL and Expression Language

File Upload

Execution Context

JSP Elements

JSP Standard Tag Libraries (JSTL)

JSP Custom Tag

... Table of Contents

(Continued from previous part...)

Response Header Lines of Static Files

Static files can be served directly by Tomcat server, if you copy the files to \local\jakarta-tomcat-4.1.18\webapps\ROOT. Tomcat server will set "Content_Type" header line based on the file name extension and the MIME settings of the server configuration. Let's look at 3 commonly used file name extensions.

1. Command: "java HttpRequestGet /hello.html 8080" gives us:

HTTP/1.1 200 OK
ETag: W/"38-1047477954000"
Last-Modified: Sat, 22 Mar 2003 14:05:54 GMT
Content-Type: text/html
Content-Length: 38
Date: Sun, 23 Mar 2003 02:59:32 GMT
Server: Apache Coyote/1.0
Connection: close

Hello world!

Couple of interesting notes here:

  • Content-Type was set to "text/html", because the file name extension was "html".
  • The request was marked as HTTP/1.0 in HttpRequestGet, but Tomcat responded with a higher version, HTTP/1.1.
  • I also tried to use HTTP/1.1 in my request, but Tomcat returned with an error. Why Tomcat could not support HTTP/1.1 request?

2. Command: "java HttpRequestGet /dot.gif 8080" gives us:

HTTP/1.1 200 OK
ETag: W/"43-1029361700000"
Last-Modified: Sun, 11 Aug 2002 21:48:20 GMT
Content-Type: image/gif
Content-Length: 43
Date: Sun, 23 Mar 2003 03:14:22 GMT
Server: Apache Coyote/1.0
Connection: close

GIF89a......

As you can see, Content_Type was set correctly to "image/gif" for file name extension "gif", as defined in the MIME settings. I could not included the entity body here because it contains binary data.

3. Command: "java HttpRequestGet /hello.pdf 8080" gives us:

HTTP/1.1 200 OK
ETag: W/"909-1059340932000"
Last-Modified: Sun, 17 Mar 2003 21:22:12 GMT
Content-Type: application/pdf
Content-Length: 909
Date: Sat, 23 Mar 2003 03:29:21 GMT
Server: Apache Coyote/1.0
Connection: close

%PDF-1.3
% ...
4 0 obj
......

Again, Content_Type was set correctly to "application/pdf" for file name extension "pdf", as defined in the MIME settings. I truncated the entity body to save some space.

(Continued on next part...)

Part:   1  2  3  4  5  6  7 

Dr. Herong Yang, updated in 2006
JSP and JSTL Tutorials - Herong's Tutorial Notes - Controlling HTTP Response Header Lines