Hi all!
Consider the code fragment below in doGet method of servlet:
---------------
response.setContentType ("application/download");
response.setHeader ("Content-Disposition", "attachment; filename=333.mp3");
---------------
after that I open file and write it to the out stream.
IE4.0 proposes to save or open 333.mp3,
but IE5.0 and higher proposes to save or open servlet's class(my), if I
press open it proposes to save or open 333.mp3.
How can I correct this???????????
IE 5.5 & Tomcat 3.1
The full source of servlet is below:
---------------
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Alex2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)throws IOException, ServletException
{
String name = "1.mp3";
response.setContentType ("application/download");
response.setHeader ("Content-Disposition", "attachment; filename=333.mp3");
ServletOutputStream op = response.getOutputStream ();
String root = this.getServletContext().getRealPath("");
InputStream in = null;
byte[] buf = new byte[response.getBufferSize()];
try {
File file = new File(root+name);
response.setContentLength((int)file.length());
in = new BufferedInputStream (new FileInputStream(file) );
int length;
while ((in != null) && ((length = in.read(buf)) != -1))
{
op.write(buf,0,length);
}
} finally {
if (in != null) in.close();
}
}
}
---------------
in HTML File <a href="servlet/Alex2" >Execute</a><p>
---------------
P.S. Sorry for bad English :(
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets