public void downLoad(String filePath, HttpServletResponse response,
boolean isOnLine) throws Exception {
File f = new File(filePath);
if (!f.exists()) {
response.sendError(404, "File not found!");
return;
}
BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
byte[] buf = new byte[1024];
int len = 0; response.reset(); 
if (isOnLine) { 
URL u = new URL("file:///" + filePath);
response.setContentType(u.openConnection().getContentType());
response.setHeader("Content-Disposition",
"inline; filename=" + f.getName());

} else { 
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition", "attachment; filename="
+ f.getName());
}
OutputStream out = response.getOutputStream();
while ((len = br.read(buf)) > 0)
out.write(buf, 0, len);
br.close();
out.close();
}
以上为提交下载的方法,希望在下载后,页面能刷新完成跳转,可是当发起response.sendRedirect();后出现异常
java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
请问如何解决?