System: Tomcat 5.5.15 Java 1.5 Solaris/SPARC Guys, new to the group, well new to tomcat completely I was hoping to get a solution for our issue. We have a piece of software that is no longer supported and I'm trying to fix an issue. The issue that when this software generates .PNG files it labels them "image1." without an extension. The problem we are having is I think there is some sort of safeguard in Tomcat that sets all extension-less files to be "text/html" content-type. This is a problem for us and I was trying to use a java tomcat filter to fix this. I've successfully built the filter here is the cut down version.
public class ImageExtFix implements Filter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; response.addHeader("JunkHeader", "WOOT"); response.addHeader("Content-Type", "image/png"); chain.doFilter(req, res); } The filter is working perfectly I can tell this because I can see my "JunkHeader" showing up on the files. However I have tried "addHeader" and "setHeader" but no matter what the Content-Type is still be forced to "index.html" I did some testing and I found that if I rename the "image1." file to "image1.tx" which is an extension that tomcat doesn't have a MIME type for, then my Filter correctly modifies this file and it gets set to "image/png" So at this point I think that there must be some sort of safe guard build into tomcat to prevent you from changing the content type of files with extensions tomcat recognizes, perhaps to prevent malicious code. Can anyone suggest an alternative to this, I've been scouring the web without much luck. I'd appreciate any suggestions keep in mind I'm pretty new tomcat/java as well so please give me keywords I can Google I would appreciate it. Thanks! John