tags:

views:

26

answers:

1

I am trying to develop a grails application that returns kml (to be viewed in Google Earth) using the controller code snippet below.

render(contentType: "application/vnd.google-earth.kml+xml", 
   view:"kml", 
  model:[feeds: feeds, feedColors: feedColors]);

This works great...but Google Earth does not open the response until it is first saved to disk and renamed with a '.kml' extension. This is very annoying and will greatly limit the use of my web application.

How do I add the .kml extension to the response name returned from grails render method?

A: 

I think this will work:

response.setHeader("Content-disposition", "attachment; filename=${filename}.kml");
render(contentType: "application/vnd.google-earth.kml+xml", 
   view:"kml", 
  model:[feeds: feeds, feedColors: feedColors]);
Javid Jamae