Hi
 
Check if you are opening another PrintWriter before the commented line. See here for more details: http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletResponse.html#getOutputStream()
 
Regards
 
Sanjeev
-----Original Message-----
From: ssmtech [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 4:42 PM
To: [EMAIL PROTECTED]
Subject: File Downloading from server

Hello All
            I have code for downloading a text file a server to the local system in a JSP page and not as a seperate Servlet,but it is giving me a  "IllegalStateException" ....the snippet of the code is
 
             String fname1 = ""+user.getBusinessId();
             String fname2 = ""+user.getAccountId();
             String fname = fname1+"-"+fname2+".txt";
             response.setContentType("text/plain");
             response.setHeader("Content-Disposition","multi-part attachment;filename=\""+fname+"\";");
             ServletOutputStream stream = null;
             try {    
             BufferedInputStream bif = new BufferedInputStream(new FileInputStream("c:/ssmtech/download/customers/"+fname)); 
            int data;
            stream = response.getOutputStream();///  It is giving me a IllegalStateException  out here.....
            while(( data = "bif.read())" != -1) {
            stream.write(data);
             }
                bif.close();
                    stream.close();
              } catch(Exception e) {
              }
                     finally {
                        if (stream != null)
                        stream.close();
          }
      
 
 
            I am working on a J2EE Application Server.....and on EJB......
            Please anybody can help me out with.this .........it is Urgent
 
 
Sam

Reply via email to