String contenttype = rs.getString("contentType");
String filename = rs.getString("fileName");
response.setContentType(contenttype);
response.setHeader("Content-disposition","attachment;filename=" + filename.replace('"', ' '));
java.io.InputStream instream = rs.getBinaryStream("fileData");
byte[] b = new byte[1000];
while (instream.read(b) > 0) {
try {
response.getOutputStream().write(b);
}
catch(Exception e) {}
}
try {
response.getOutputStream().flush();
}
catch(Exception e) {}
String contenttype = rs.getString(contentType); String filename = rs.getString(fileName); response.setContentType(contenttype); response.setHeader(Content-disposition,attachment;filename= + filename.replace(”, ‘ ‘));
Share
Normally, it should allow calling
response.getOutputStream()any number of times. I think you are calling bothresponse.getOutputStream()andresponse.getWriter().Please check if you are calling
response.getWriter()anywhere or is the request is landing in JSP which writes toresponse.getWriter().