본문 바로가기

프로그래밍관련/java

JSP POST request 한글처리 후 엑셀저장

<%@ page language="java" contentType="text/html; charset=euc-kr"%>
<%request.setCharacterEncoding("MS949");
response.setContentType("application/vnd.ms-excel; charset=euc-kr");
String fileName = "엑셀파일명";
response.setHeader("Content-Disposition", "filename="+fileName+".xls");
response.setHeader("Content-Description", "JSP Generated Data");

String clientBrowser= new String(); // 브라우저 버전
 
clientBrowser=request.getHeader("User-Agent");

if (clientBrowser.indexOf("MSIE 5.5")>-1 || clientBrowser.indexOf("MSIE 6.0") > -1)
{
 response.setHeader("Content-Disposition","attachment;filename="+fileName+".xls");
}
else
{
 response.setHeader("Content-Disposition","filename="+fileName+".xls");
}
%>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<%=request.getParameter("htmlValue")%>
</body>
</html>