When deploying a .war file to a GlassFish Server (4.1 currently), the GF server automatically delivers files from the WEB-INF/
folder. (Unless I override their addresses by specifying a Servlet, that is.)
Actually when deploying the .war file to the GF server, it extracts those files under WEB-INF/
to {gf-home}/glassfish/domains/domain1/applications/{app-name}
.
Then it delivers them when accessing http://{hostname}:8080/{app-name}/{path}
.
Now when accessing .json files, the server does NOT send the HTTP Content-Type: application/json
header.
This results in the page not loading properly, FireFox console showing me a XML Parsing Error: not well-formed
exception, even though the file contents are exactly the same.
So my guess is that it's the missing Content-Type tag.
How can I change this mime-mapping for the app/project itself?
From the pages I have seen so far, it is possible to redefine this behaviour in the {gf-home}/glassfish/domains/domain1/default-web.xml
file, defining the mime-mapping
. But presuming I cannot access that file, only upload .war files. Is there any solution? Is it possible to pack a default-web.xml
somewhere into the .war file?
The other solution I can think of at the moment is to override the specific .json files' addresses with a servlet and adding the Content-Type
header in Java. But I'm not sure if there is a foolproof way of accessing and reading the .json files at runtime, but without moving them anywhere in the Java source code, but leaving them in the WEB-INF/ folder? Any suggestions?