I'm trying to serve SVG images as package resources. However, when I do so, the image files are served with a mime-type of application/xml, rather than the correct image/svg+xml. This causes strange behavior in Google Chrome - the image displays as a broken link when included in an <img/> tag, but renders fine when the image URL is opened directly. If the resource is served from the main webapp directory rather than as a package resource, the correct mime-type is sent and Chrome displays the image properly.
Delving into the code, it appears that the problem is Java's URLConnection.guessContentTypeFromStream() method, which doesn't support SVG files. I've verified this problem on both the Apple-supplied Java 1.6 and the official Oracle Java 1.7, both on MacOS X. What would be the best way to work around this issue? I tried creating my own custom PackageResource wrapper, which had its own PackageResourceStream wrapper, but it quickly got unwieldy (as well as being a nightmare for future maintainability). My goal is to have a subclass of Image that returns either a reference to an SVG or a PNG depending on the browser version. I first noticed the mime-type problem with my subclass, but I verified that it also exists when using the standard Image class. Thanks in advance for your help! -Chris Snyder -- Chris Snyder Web Developer, BioLogos 616.328.5208 x203 biologos.org
