tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dunlop, Aaron" <aaron.dun...@transcore.com>
Subject HttpServletResponse.setStatus and setContentType
Date Tue, 07 Dec 2004 22:44:19 GMT
I have a standard HTTP servlet acting as an XML web service endpoint, running on an embedded
Tomcat 5.0.30. 

I of course use HttpServletResponse.setContentType to specify that the response is "text/xml".
When the request is successful and I set a 2xx HTTP response code, the Content-Type header
looks as expected. But if an error is detected and I return an HTTP error code (using setStatus),
the Content-Type header specifies "text/html;charset=utf-8" instead of "text/xml".

It doesn't seem to matter whether I call setContentType before or after setStatus, and all
the 4xx and 5xx codes I've tried trigger this behavior.

I'd just ignore it, but unfortunately, the WSI Basic Profile specifies that a SOAP fault must
return a 500 along with the XML fault. And some clients (ahem... .NET...) seem to choke trying
to parse the fault when the wrong content-type is returned.

I didn't find anything in the specs or documentation that indicated to me that this was required
behavior, but perhaps I'm missing something.

Any ideas?

Thanks in advance,
Aaron Dunlop


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message