send file to the client/ jspsmart

Hello I send a file to the server using the MultpartUpload of O'reilly. Now i want to send a file from the server to the client. I am trying to use the jspsmartUpload to do it using the following code in a jsp file (save.jsp): "<%@ page contentType="text/html;charset=ISO-8859-1" %> <jsp:useBean id="dadosSessao" scope="session" class="beans.DadosSessao" /> <% // No cache. response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); %> <%@ page language="java" import="com.jspsmart.upload.*"%> <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><% // Initialization with jspSmartUpload v2.1 mySmartUpload.initialize(pageContext); // Download mySmartUpload.downloadFile("c:\\jakarta-tomcat-3.2.3\\webapps\\PS2\\WEB-INF\\classes\\uploaddir\\" + dadosSessao.getFichNameEUR); %>" When i click on the button which action is the save.jsp with the code above, he sends the text that is in the file but gives the following error: "Error: 500 Location: /PS2/save.jsp Internal Servlet Error:java.lang.IllegalStateException: OutputStream is already being used for this request at org.apache.tomcat.facade.HttpServletResponseFacade.getWriter(HttpServletResponseFacade.java:175) at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:166) at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:158) at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:205) at _0002fsave_0002ejspsave_jsp_1._jspService(_0002fsave_0002ejspsave_jsp_1.java:142) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at java.lang.Thread.run(Thread.java:484)" Can anyone help me? I don't know where to look! Thanks Claudia Vaz

This error comes when you try to use both response.getWriter() and response.getOutputStream() in the same servlet. Tomcat when compiling the JSP page to a servlet uses the getWriter() method. So the error may be caused as the jspSmartUpload may be using the response.getOutputStream() to write the contents of the file to the client for downloading. I am not sure how to fix this. Will get back to you if I find out. ------------------ --:Biju:--