<%@ page language="java" contentType="text/html; charset=MS949"
pageEncoding="MS949"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.math.*" %>
<%@ page import="java.io.*" %>
<%
response.setHeader("Content-Disposition", "attachment; filename=excel.xls");
response.setHeader("Content-Description", "JSP Generated Data");
request.setCharacterEncoding("MS949");
String sqltext = "select * from ca_aaa";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xxx", "xxx", "xxx");
pstmt = conn.prepareStatement(sqltext);
//pstmt.setString(1,"");
rs = pstmt.executeQuery();
%>
<table border='1'>
<%
%><tr><td>제목</td><td>내용</td></tr><%
while(rs.next()){
%><tr><%
%><td style='mso-number-format:\@'><%=rs.getString(1)%></td><%
%><td style='mso-number-format:\@'><%=rs.getString(2)%></td><%
%></tr><%
}
%>
</table>
<%
}
catch(Exception e){
e.printStackTrace();
}
finally{
if(rs!=null){try{rs.close();}catch(Exception e){}}
if(pstmt!=null){try{pstmt.close();}catch(Exception e){}}
if(conn!=null){try{conn.close();}catch(Exception e){}}
}
%>
'Java+Jsp' 카테고리의 다른 글
jsp ftp (Commons net) (0) | 2010.02.18 |
---|---|
jsp file upload (MultipartRequest ) (0) | 2010.02.18 |
java 디컴파일러 JAD, JADClipse (0) | 2009.11.13 |
xml 읽어오기 (0) | 2009.11.02 |
페이징 처리 (0) | 2009.10.29 |