jsp导出excel有关问题

jsp导出excel问题
写了一个从JSP导出excel的程序,功能也实现了
在这个JSP上还有几个按钮,当电击“导出Excel”按钮后,再点击这个JSP页面中的其它几个按钮时,还是导出excel,如果先点不在这个JSP页面中的按钮再点击这个JSP页面中的按钮的话,则是好的。可能是response的header需要重新设置过,不过搞了很久还是不行,希望大家指教!

------解决方案--------------------
你可以把这个按钮放在单独的FORM里试试.
------解决方案--------------------
可以用servlet实现跳转redirectnameExcel.xls就行了。


//拼凑excel文件名字
String filename = String.valueOf(year)+String.valueOf(month)+String.valueOf(day)+h+mise+".xls";
String path = getServletContext().getRealPath("excelexport");
System.out.println("path:"+path);
try{
FileOutputStream fos = new FileOutputStream(path+"/"+filename); 

// 创建新的Excel 工作簿
HSSFWorkbook wb = new HSSFWorkbook(); 
// 在Excel 工作簿中建一工作表
HSSFSheet s = wb.createSheet(); 
String sheetName = year+"-"+month+"-"+day;
wb.setSheetName(0, sheetName); 
//在索引0的位置创建行(第一行)
HSSFRow row = s.createRow((short)0); 
HSSFCell cell0 = row.createCell((short) 0);// 第一列
HSSFCell cell1 = row.createCell((short) 1);
HSSFCell cell2 = row.createCell((short) 2);
HSSFCell cell3 = row.createCell((short) 3);
HSSFCell cell4 = row.createCell((short) 4);
HSSFCell cell5 = row.createCell((short) 5);
HSSFCell cell6 = row.createCell((short) 6);
// 定义单元格为字符串类型
cell0.setCellType(HSSFCell.CELL_TYPE_STRING);
cell1.setCellType(HSSFCell.CELL_TYPE_STRING);
cell2.setCellType(HSSFCell.CELL_TYPE_STRING);
cell3.setCellType(HSSFCell.CELL_TYPE_STRING);
cell4.setCellType(HSSFCell.CELL_TYPE_STRING);
cell5.setCellType(HSSFCell.CELL_TYPE_STRING);
cell6.setCellType(HSSFCell.CELL_TYPE_STRING);

cell0.setEncoding(HSSFCell.ENCODING_UTF_16);
cell1.setEncoding(HSSFCell.ENCODING_UTF_16);
cell2.setEncoding(HSSFCell.ENCODING_UTF_16);
cell3.setEncoding(HSSFCell.ENCODING_UTF_16);
cell4.setEncoding(HSSFCell.ENCODING_UTF_16);
cell5.setEncoding(HSSFCell.ENCODING_UTF_16);
cell6.setEncoding(HSSFCell.ENCODING_UTF_16);
// 在单元格中输入数据
cell0.setCellValue("科室名");
cell1.setCellValue("版组");
cell2.setCellValue("注册名");
cell3.setCellValue("问题题目");
cell4.setCellValue("问题内容");
cell5.setCellValue("发表时间");
cell6.setCellValue("Status");
KSuser ks =new KSuser();

HSSFRow[] rows = null;
if(list != null && list.size()>0){
rows = new HSSFRow[list.size()];
}
int j = 1;
for(int k=0;k<list.size();k++){
ks =list.get(k);
//设置行从第二行开始
rows[j-1] =s.createRow((short)(j));
String[] str =new String[7];
str[0]=ks.getKeshi();
str[1]=ks.getBanzu();
str[2]=ks.getReg_name();
str[3]=ks.getSubject();
str[4]=ks.getText();
str[5]=ks.getRe_day().toString();
str[6]=ks.getStatus();
for(int i=1;i<8;i++){
HSSFCell cell =rows[j-1].createCell((short)(i-1));
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(str[i-1]);
}
j++;
}

wb.write(fos);
fos.close();
}catch(Exception e){
e.printStackTrace();
out.println("<script>alert('异常操作,文件可能正保护中\\n请重试!');history.go(-1);</script>");
}
String urlname = request.getRequestURI();
urlname = urlname.replaceAll("excel", "excelexport");