teknopaul
teknopaul

Reputation: 6762

How to add content-Type headers in tomcat 8

I'm serving .js files from inside a war in tomcat8. Its adding only these two headers.

Date:   Mon, 12 Feb 2018 16:14:13 GMT
ETag:   W/"3087-1518446418000"

(verified in two browsers)

tomcat/conf/web.xml specifies

<mime-mapping>
    <extension>js</extension>
    <mime-type>application/javascript</mime-type>
</mime-mapping>

To be sure I added in my war's web.xml too.

Any ideas what might be causing this?

Tomcat 8, all pretty standard, its a while since I tried serving static content from tomcat but I have a reason to do that.

web.xmlheader is currenlty (tried other ones)

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">

Upvotes: 1

Views: 688

Answers (1)

teknopaul
teknopaul

Reputation: 6762

Answering my own question here. My problem was not generic to all JavaScript.

I had a servlet mapped to

<url-pattern>/foo</url-pattern>

And a JavaScript file called

/js/foo.js

Tomcat was able to correctly resolve the servlet and the JS file but something broke the headers in the process, I'm going to raise a bug report with Tomcat.

Upvotes: 1

Related Questions