When you deploy the .war file to the GlassFish server (currently in 4.1), the GF server automatically sends files from the WEB-INF/ folder. (If I do not redefine their addresses by specifying a servlet, that is.)
In fact, when you deploy a .war file to a GF server, it extracts files under WEB-INF/ up 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 header Content-Type: application/json . This causes the page to not load properly, the FireFox console shows me the XML Parsing Error: not well-formed exception, although the contents of the file are exactly the same. Therefore, I assume this is a missing Content-Type tag.
How can I change this mime-mapping for the application / project itself?
From the pages I've seen so far, you can override this behavior in the {gf-home}/glassfish/domains/domain1/default-web.xml , defining mime-mapping . But, believing that I cannot access this file, download only .war files. Is there a solution? Is it possible to pack default-web.xml somewhere in a .war file?
Another solution that I can think of at the moment is to redefine the addresses of specific .json files with a servlet and add a Content-Type header in Java. But I'm not sure if there is a reliable way to access and read .json files at runtime, but not moving them anywhere in the Java source code, but leaving them in the WEB-INF / folder? Any suggestions?
source share