import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Download extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
try
{
//这里你可以做些其他的事情
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=/"你要在保存窗口中显示的保存文件名/"");
ServletOutputStream out = response.getOutputStream();
BufferedReader br=new BufferedReader(new FileReader(要下载的的文件名));
String line=br.readLine();
while (line!=null)
{
out.write(line.getBytes());
out.println();
line=br.readLine();
}
out.close();
br.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doGet(request, response);
}
}