tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <>
Subject RE: How send svg content to browser as response
Date Tue, 05 Sep 2006 10:14:48 GMT
> From: prad [] 
> Am processing some svg files on server side and after 
> processing i need to
> send the svg as response...I set the mime type as "image/svg+xml"
> and  tried the below code
>  public void doGet(HttpServletRequest request,
>                       HttpServletResponse response)
> 		    throws ServletException, IOException{
> 	response.setContentType("text/html");

Erm?  I thought you said you were setting the type to SVG?

> 	PrintWriter out = response.getWriter();
> 	out.println("<html>");
> 	out.println("  <head>");
> 	out.println("    <title>SimpleServlet</title>");
> 	out.println("  </head>");
> 	out.println("  <body>");
> 	out.println("    Hello, World");
> 	out.println("  </body>");
> 	out.println("</html>");
>     }
> when i invoke this servlet's showing download dialog 
> box and if
> press ok .....servletName.svg file gets downloads
> Why its not directly displaying the contents in the 
> browser...Any help plz..

Firstly I'd send some valid SVG, not HTML, as the payload.

Secondly does your browser have SVG handling, either natively or via a

Thirdly have you used any tool such as ieHttpHeaders to check the

Fourthly, are you using Internet Explorer?  It has a nasty habit of
using the URL's extension to guess the type of the downloaded content
rather than replying on the MIME type.  If you're serving the content
with a .svg extension and don't have a plug-in that accepts the content,
IE may well offer to save the file rather than display HTML.

		- Peter

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message