2010. 8. 6. 18:19 flex
[12-D4][notice][JSP] Eclipse 프로젝트 설정, 글 목록(list.jsp)
[12-D4][notice][JSP] Eclipse 프로젝트 설정, 글 목록(list.jsp)
[01] JSP server Page
- JDBC 설정: 'www.utility' Package 복사
- Oracle Driver 'ojdbc.jar' 복사
1. Server Page 설정
- Eclipse setting
. workspace : workspace_flex_www
. project type: Dynamic Web Project
. project name: www_flex
2. 목록
>>>>> www_flex/WebContent/noticefxjsp/list.jsp
<?xml version="1.0" encoding="utf-8"?>
<%@ page contentType="text/xml; charset=utf-8" %>
<%@ page import = "java.sql.*, www.utility.*" %>
<jsp:useBean id="dbconnect" class="www.utility.ConnectionMgr" scope="page" />
<%
//브러우저의 캐시 영역에 저장하지 말것을 지정.
//플렉스 데이터그리드에서 새로고침 안됨.
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires",0);
%>
<%
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer sql = new StringBuffer();
out.println("<result_set>"); // root 태그
try {
con = dbconnect.getConnection();
sql.append(" SELECT idx, regdate, subject, content, passwd");
sql.append(" FROM noticeFx ");
sql.append(" ORDER BY idx DESC");
pstmt = con.prepareStatement(sql.toString());
rs = pstmt.executeQuery();
int proc_cnt = 0;
while (rs.next()) {
out.println("<record>"); // 레코드와 1:1로 매핑
out.println(" <idx>" + rs.getString("idx") + "</idx>");
out.println(" <regdate>" + rs.getString("regdate") + "</regdate>");
out.println(" <subject>" + rs.getString("subject") + "</subject>");
out.println(" <content>" + rs.getString("content") + "</content>");
out.println(" <passwd>" + rs.getString("passwd") + "</passwd>");
out.println("</record>");
proc_cnt++;
}
// 에러코드 --> 0: 정상, 1:에러
out.println("<result_meta>");
out.println(" <err_code>0</err_code>"); // 에러코드
out.println(" <proc_cnt>" + proc_cnt + "</proc_cnt>");// 처리건수
out.println(" <message/>"); // 메시지
out.println("</result_meta>");
} catch (Exception e) {
System.out.println(e.toString());
out.println("<result_meta>");
out.println(" <err_code>9</err_code>"); // 에러코드
out.println(" <proc_cnt>0</proc_cnt>");// 처리건수
out.println(" <message>글 목록을 가져오지 못했습니다.</message>"); // 메시지
out.println("</result_meta>");
} finally {
DBClose.close(con, pstmt, rs);
out.println("</result_set>");
}
%>
'flex' 카테고리의 다른 글
[14-D4][notice][JSP] 글 추가, 글 수정, 글 삭제 (0) | 2010.08.06 |
---|---|
[13-D4][notice] MXML main 화면(noticeFx.mxml) (0) | 2010.08.06 |
[11-D3][notice] DTO, Manager의 제작 및 사용 (0) | 2010.08.06 |
[10-D3][notice] DB, ActionScript Class, getter, setter function (0) | 2010.08.06 |
[09-D3] Container & Component 배치 (0) | 2010.08.06 |