代码
<%@ page import="java.io.OutputStream" %>
<%--
Created by IntelliJ IDEA.
User: czy
Date: 2010-3-31
Time: 23:20:32
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=gbk" language="java" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
<%
String fileName = "hello.txt";response.setContentType("text/plain");
response.setHeader("Location", fileName);
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
OutputStream outputStream = response.getOutputStream();
String s = "hello world";
byte[] buffer = new byte[1024];
outputStream.write(s.getBytes());
outputStream.flush();
outputStream.close();
out.clear();
out=pageContext.pushBody();
%>
</body>
</html>