I am writing a JSP application and am deploying it to JBoss 5.0. When I attempt to retrieve my CSS or Javascript files, JBoss returns the wrong Content-type for the file, so Firefox refuses to execute code supplied in them. Here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>TestServlet</display-name>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>org.example.TestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/engine/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
/login.jsp
</welcome-file>
</welcome-file-list>
<jsp-config>
<jsp-property-group>
<display-name>TestServlet</display-name>
<url-pattern>/*</url-pattern>
<el-ignored>false</el-ignored>
<scripting-invalid>false</scripting-invalid>
<is-xml>false</is-xml>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
</web-app>
Using lynx to test the file download, I get the following:
host> lynx http://devbox:8080/TestServlet/js/main.js -head -dump
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Set-Cookie: JSESSIONID=EA6FFF63B00F0B8C0C44F7A79BD368CF; Path=/jclaim
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1778
Date: Sun, 24 May 2009 17:53:31 GMT
Connection: close