%@ page contentType="text/html; charset=UTF-8"%> <%@ page import="com.forgon.tools.*,org.apache.commons.lang.*"%> <%@page import="java.io.IOException"%> <%@page import="sun.misc.BASE64Decoder"%>
<% String htmlTable = request.getParameter("htmlTable"); String fileName = request.getParameter("htmlFileName"); if(htmlTable != null){ ServletOutputStream servletOutputStream = response.getOutputStream(); response.setContentType("application/octet-stream"); response.addHeader("Content-Disposition","attachment;filename=" + new String(fileName.getBytes("GBK"), "ISO8859_1")); try{ BASE64Decoder decoder = new BASE64Decoder(); servletOutputStream.write(new String(decoder.decodeBuffer(htmlTable)).getBytes("UTF-8")); }catch(IllegalArgumentException e){ e.printStackTrace(); }catch (Exception e) { e.printStackTrace(); }finally { try { servletOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } servletOutputStream.flush(); out.clear(); out = pageContext.pushBody(); } %>