Salvar arquivo xml ao inves de abrir no IE

Uma ajuda por favor

Tenho um link que abre um xml, mais gostaria de salvar esse arquivo ao invés de abrir no IE

o codigo é esse


<a >Download da chave de ativação</a>

alguém te a solução desse caso

Clicar com o botão direito e selecionar “Salvar link como’” ?

acho que essa não serio uma pratica muito boa para usuario né

parece que o Response.ContentType faz alguma coisa do tipo

alguem sabe de alguma coisa?

Se está disponível no navegador, acho que é uma prática válida mas isso é outra história.

[quote=jemoliveira]parece que o Response.ContentType faz alguma coisa do tipo

alguem sabe de alguma coisa?[/quote]

A interface ServletReponse possui o seguinte método para especificar o tipo de conteúdo:

[quote=“A santa API”]setContentType

public void setContentType(java.lang.String type)
Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. The response’s character encoding is only set from the given content type if this method is called before getWriter is called.

This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after getWriter has been called or after the response has been committed.

Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the Content-Type header is used.

Parameters:
    type - a String specifying the MIME type of the content[/quote]

Em um simples Serlvet esse método deve funcionar mais ou menos assim:

[code]public class PJServlet extends HttpServlet {

 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
       
     String file = "xmlfile.xml";  
               
     try{  
         response.setContentType("application/xml");  
         response.setHeader("Content-Disposition", "atachment; filename=\"" + file);  
     }catch(Exception e){  
         throw new ServletException("Erro ao abrir XML", e);
     }  
       
 }  

} [/code]

Se não funcionar como o Guilherme passou, tente setar o content-type para application/octet-stream:

response.setContentType("application/octet-stream");