Found out that the page content type which comes back is text/html which prompts me to save the image/svg+xml content. Why is that?
Also one interesting thing is that, the same setup works (displays the SVG on browser) with Opera but fails with IE6 and NN6.
You sure the content-type is the first thing you send on the output stream? I'm a bit vague on this but I think it has to be the first thing on the page before any text output. If it is not, I think it is ignored as the content-type has defaulted because "display" data has already been sent.
I don't think defining the mime-types in web.xml has any effect on dynamic content, only static-content - associates file postfix with content-type. Dynamic content is governed entirely by the content-type you specify for the stream (where the default is HTML).
Okay. Here is what I have found out so far and I am including some gripes and ahh!s.
Browsers and their quirks
IE - You need to request the SVG with an .svg or .svgz extension as IE doesn't care about MIME types. Also, we need to embed the SVG (with proper width and height specified) else IE will try to download the file.
Opera - As far as I can tell, it doesn't work with embedding SVG. It needs to be sent to the browser directly. MIME type necessary and it has to be the first thing sent to the browser. Cannot have any spaces/newlines before the contentType is sent to the browser.
Netscape - Has version problems so I am going to talk about versions and their quirks below:
Netscape 6 - Adobe SVG Viewer WILL NOT work with this as apparently some mismatch in implementation (http://support.adobe.com/devsup/devsup.nsf/docs/51392.htm).
Netscape 7 - Mozilla states that Netscape 7 does not have SVG support "turned on" by default and we need to do some stuff to turn it on. This will not work even if we install Adobe SVG viewer. So, what it does is it recognizes the image/svg+xml MIME type and asks the user whether he wants to open it in Adobe (the associated application for SVG) or Save it to disk. If you choose Adobe, lo! and behold!, it opens in IE as IE is the default browser and Adobe's SVG Viewer is associated with only that. So, even if you send the correct MIME type and without any spaces at the top, it won't work as you expect it to work.
For all browsers I tested this stuff, I had to remove all spaces, comments etc in my JSP as it introduces spaces above my SVG which craps out promptly at the browser. Grrr!!
So, all in all, I have spent (read as wasted) 11 hrs on this application just to display a simple SVG file. After all this work, am I still done?!! Noooo!!! I am still stuck. Wanna guess why?!! Because, embedding in IE requires me to specify the dimensions and I have to figure out the dimensions dynamically.
So, any help in figuring out the dimensions dynamically for a SVG file will be much appreciated.
Thanks in advance.