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