tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Request for 'Scriptresource.axd' results in download of 'Scriptresource.txt'
Date Tue, 24 Feb 2009 15:28:23 GMT
Hash: SHA1


On 2/23/2009 3:00 PM, Mark Kimmerly wrote:
> I have written a servlet request filter that inspects the URI of
> incoming requests and redirects them to an IIS server if appropriate
> (such as when a .aspx resource is requested).  To summarize, the filter
> constructs an HttpURLConnection to the IIS server, transfers the GET or
> POST data from the original request to the HttpURLConnection, makes the
> connection, grabs the response from IIS and writes it to the
> HtpServletResponse stream.

Note that this isn't redirection, it's proxying. If you aren't issuing a
3xx response code, it's not redirection.

> This redirection works for most content, but for some reason certain
> files get delivered to the client with the wrong extension.  In
> particular, all ".axd" files end up on the client as ".txt" files.

What do you mean the wrong extension? The URL should dictate the file's
"extension" should the browser choose to download (unless you use a
Content-Disposition header, which I suspect you aren't using).

> I've
> tried setting up a mime-mapping for ".axd" files (as text/javascript) in
> my web.xml, but it didn't solve the problem.

The only thing this changes is the MIME type used to reply to the client.

> Does anyone out there know why the extension gets changed?  Maybe I'm
> leaving out header information when I forward the request on to IIS?

If you mean that the client is interpreting the files as text/plain
instead of text/javascript or text/html or whatever, then that's a MIME
type problem: your Content-Type header is wrong on the response you send
to the client.

You should be copying the Content-Type from IIS's response and setting
that as the Content-Type for the response you send back to the client.
You should set this before you send any of the content.

Also note that MSIE ignores Content-Type headers because it thinks it's
smarter than you are.

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message