从网上下的
是关于jsp实现文件下载的,该怎么设置或者怎么做的呢,拜托拜托了.
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>

<%
// example:
// <a href="download.jsp?path=img/&name=test.gif">download image</a>

String root = getServletContext().getRealPath("/");
String path = request.getParameter("path");
String name = request.getParameter("name");

response.setContentType("unknown");
response.addHeader("Content-Disposition", "filename=\"" + name + "\"");

try
{
java.io.OutputStream os = response.getOutputStream();
java.io.FileInputStream fis = new java.io.FileInputStream(root + path + name);

byte[] b = new byte[1024];
int i = 0;

while ( (i = fis.read(b)) > 0 )
{
os.write(b, 0, i);
}

fis.close();
os.flush();
os.close();
}
catch ( Exception e )
{
} %>
我直接运行出现:
exception

java.lang.IllegalStateException: getOutputStream() has already been called for this response
    org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:609)
    org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:190)
    org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:165)
    org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:158)
    org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:234)
    org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:160)
    org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:120)
    org.apache.jsp.get.download_005fdo_jsp._jspService(download_005fdo_jsp.java:95)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

错误,具体我该怎么做呢?
先谢谢了