tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <Peter.Crowt...@melandra.com>
Subject RE: How send svg content to browser as response
Date Tue, 05 Sep 2006 10:14:48 GMT
> From: prad [mailto:prad4svg@yahoo.co.in] 
> 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 .....it'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
plug-in?

Thirdly have you used any tool such as ieHttpHeaders to check the
content-type?

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: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message