2014-10-08
1. 로그인 후 글쓰기
jsp파일에서<c:if test="${memId == null}"> 로 로그인 설정 하여 로그인 되었을 때
글쓰기 버튼 활성화
2. 작성자는 로그인된 ID
작성자 : ${memID}
3. 나의 작성 글목록
자바파일에서 String id = (String)session.getAttribute("memID");
id값으로 쿼리문 날려서 결과 값을 받은 후
list= select * from board where id=?
글 리스트 자바파일에서
request.setAttribute("list", list);
값을 넣고 리스트 jsp파일에서
<c:forEach var="list" items="${list}">
와 같이 넣는다
4. 비밀번호 확인 후 글 읽기 + 관리자는 모두 읽기 가능
클릭한 글 번호
int num = Integer.parseInt(req.getParameter("num"));
와 해당 글의 비밀번호
String passwd = request.getParameter("passwd");
를 받고 해당 글의 번호와 비밀번호를
int check = selct passwd from board where num=?
하여 쿼리문을 날려서 받아옴
리턴 받은 값을
자바 파일에서 if문을 사용하여 비밀 번호가 같으면 글 내용을
if(check ==1){ 글 내용 페이지}
}else{
경고 창 띄움
}
5. 관리자만 답변가능
관리자 ID(adminID)설정 된 상태에서
String id = (String)session.getAttribute("memId");
로그인된 ID와 관리자와 같으면
if(id.equals("adminID)){
String adminID = "adminID";
req.setAttribute("adminID", adminID);
}
JSP 파일에서 로그인 된 ID와 관리자 ID가 같으면
<c:if test="${memId == adminID}">
답변 버튼 기능 활성화
6. 관리자만 글쓰기 가능
관리자 ID(adminID)설정 된 상태에서
String id = (String)session.getAttribute("memId");
로그인된 ID와 관리자와 같으면
if(id.equals("adminID)){
String adminID = "adminID";
req.setAttribute("adminID", adminID);
}
JSP 파일에서 로그인 된 ID와 관리자 ID가 같으면
<c:if test="${memId == adminID}">
글쓰기 버튼 기능 활성화
7. 쿠키를 활용한 자동 로그인
쿠키 생성
Cookie coo1 = new Cookie("memId", "id");
Cookie coo2 = new Cookie("passwd", "passwd");
coo1.setPath("/");
coo2.setPath("/");
coo1.setMaxAge(3000); //쿠키 시간 설정
coo2.setMaxAge(3000);
response.addCookie(coo1);
response.addCookie(coo2);
쿠키 불러오기
Cookie[] cookies = request.getCookies();
if(cookies != null){
for(int i = 0; i < cookies.length; i++){
Cookie thisCookie = cookies[i];
HttpSession session = reqeust.getSession();
session.setAttribute("memId", id);
}
}