"Craig R. McClanahan" wrote:
>
> Jean-Michel Leon wrote:
>
> > >
> > > > I'm not sure if this is compliant with the spec
> > >
> > > So check out the JSP spec.
> >
> > I did. It's just that the spec (JSP 1.0, p43, 2.7.1) doesn't say that
> > this is the only way people should use to set the mime type. Since in
> > our case, the mime type is not static for this page (it's computed based
> > on the user agent we're talking to), I believe (correct me if I'm wrong)
> > I can't do that with the page directive.
> >
>
> You are right, you cannot set a dynamic content type with the page directive. But
> I believe calling Tomcat's behavior with respect to setting the content type a
> "bug" is really presumptuous.
>
> The behavior is deliberate in the Tomcat code -- it sets the "Content-Type" header
> itself based on whatever you specify as an argument to setContentType() --
> defaulting to "text/html" if you have not called this method. The fact that
> you've set a header yourself with the same header type creates a second one, which
> the browser (quite correctly) ignores.
ok, you convinced me, it's deliberate bug :-)
My header is simply not passed. I don't know what tomcat is doing, I
don't get two headers as suggested, here is exactly what I get:
---------------------------------------------------------------------
GET /debug/header.jsp HTTP/1.0
HTTP/1.0 200 OK
Status: 200
ContentType: foo/mispelled
Date: Mon, 17 Jan 2000 06:26:46 GMT
Content-Type: text/html
Servlet-Engine: Tomcat Web Server/3.0 (JSP 1.1; Servlet 2.2; Java 1.2.2;
Windows NT 4.0 x86; java.vendor=Sun Microsystems Inc.)
---------------------------------------------------------------------
where header.jsp contains:
<%
response.setHeader("Content-Type","foo/bar");
response.setHeader("ContentType","foo/mispelled");
%>
which leads me to believe that tomcat is simply setting the
'Content-Type' header, without checking if this one has already been set
(using containsHeader). tomcat is simply calling setHeader which
overwrites my previous call; and this is correct, according to the
servlets spec.
this deliberate behavior in tomcat is wrong (i.e. it's a bug), because
the servlet spec does not specify that servlets should override the
programmer's contnet-type wth its own defaults.
jm.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html