'조회수'에 해당되는 글 2건

  1. 2009.03.02 [게시판] 글 조회수
  2. 2009.02.25 [게시판] 쿠키 사용하기

[게시판] 글 조회수

자료 2009. 3. 2. 10:00
...
Connection con = null;
PreparedStatement pstmt = null;
...

try{
...(커넥션 얻기)
StringBuffer addCount = new StringBuffer();
addCount.append("update board set readcount = readcount+1 where num=?");
pstmt = con.prepareStatement(addCount.toString());
pstmt.setInt(1,num);
pstmt.executeUpdate();
...
}
...

이것은 누구나 아는 방법.
보통 글 번호에 따른 게시물을 읽는 코드와 같이 쓴다.(파라미터로 글 번호를 받기 때문에)
Posted by zeide
,
1. 쿠키 심기
  Cookie cookie = new Cookie(name, value);
  cookie.setMaxAge(limit);
  cookie.setPath("/");
  response.addCookie(cookie);

2.쿠키 얻기
Cookie[] cookies = request.getCookies();
  String str = "";
  
  if(cookies!=null){
   for(int i=0;i<cookies.length;i++){
    if(ckname.equals(cookies[i].getName())){
     str = URLDecoder.decode(cookies[i].getValue(),"utf-8");
    }//if
   }//for
  }//if

Posted by zeide
,