super.init(config);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
DbCon dbCon = new DbCon();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String viewMode = CommonUtil.nchk(req.getParameter("viewMode"),"W");
String resultPage = null;
ArrayList<DownFile> arrdf;
/*
seq ��ȣ ��������
*/
int seq = 0;
try {
seq = Integer.parseInt(req.getParameter("seq"));
} catch (Exception e) {
}
/*
db ��������
*/
try {
conn = dbCon.getConnection();
// �Խù� ��������
Article one = new ArticleDao().getArticle(seq, conn);
// email filtering
one.setEmail(CommonUtil.rplc(one.getEmail(), "@", "@"));
one.setContent(CommonUtil.rplc(one.getContent(), "@", "@"));
String bbs = one.getBbs();
boolean valid = new BbsRoleHandler().getPermission((Member)req.getSession().getAttribute("member"), bbs);
if (valid) {
req.setAttribute("one", one);
} else {
res.sendRedirect("/jsp/member/login.jsp");
}
// file list ��������
arrdf = new ArrayList<DownFile>();
pstmt = conn.prepareStatement(QUERY_FILE);
pstmt.setInt(1, seq);
rs = pstmt.executeQuery();
while (rs.next()) {
arrdf.add(
new DownFile(
rs.getInt(1),
CommonUtil.a2k(rs.getString(2)),
rs.getString(3),
rs.getLong(4),
rs.getInt("download")));
}
rs.close();
pstmt.close();
req.setAttribute("arrdf", arrdf);
// ��ȸ�� �����ϱ�
/*pstmt = conn.prepareStatement(QUERY_COUNT_UP);
pstmt.setInt(1, seq);
pstmt.executeUpdate();
pstmt.close();*/
// ������ ��ȣ ��������
pstmt = conn.prepareStatement(QUERY_PREV);
pstmt.setString(1, bbs);
pstmt.setInt (2, one.getRef());
pstmt.setInt (3, one.getRef());
rs = pstmt.executeQuery();
if(rs.next()) {
req.setAttribute("prevSeq", rs.getString("seq"));
req.setAttribute("prevSubject",
CommonUtil.a2k(CommonUtil.rplc(rs.getString("subject"), "{", "{")));
}
rs.close();
pstmt.close();
// ������ ��ȣ ��������
pstmt = conn.prepareStatement(QUERY_NEXT);
pstmt.setString(1, bbs);
pstmt.setInt (2, one.getRef());
rs = pstmt.executeQuery();
if(rs.next()) {
req.setAttribute("nextSeq", rs.getString("seq"));
req.setAttribute("nextSubject",
CommonUtil.a2k(CommonUtil.rplc(rs.getString("subject"), "{", "{")));
}
rs.close();
pstmt.close();
} catch (Exception e) {
System.out.println("ViewServlet err:" + seq + "|" + e.toString());
} finally {
dbCon.close(conn, pstmt, rs);
}
// Web ����� Mobile ���� ����
if ( "IUI".equals(viewMode) ) {
resultPage = "/iui/view.jsp";