본문 바로가기
STUDY/JSP

회원가입(서블릿) - index.jsp

by Anne of Green Galbes 2019. 2. 26.

1. index.jsp


① session 값을 사용하는 방법

○ session값 가져오기

- 변수형 변수명 = (변수형)session.getAttribute("session에 올린 변수명")

- session에 올린 값은 변수형이 object이므로 다운캐스팅 해줘야한다.

- CustomInfo info = (CustomInfo)session.getAttribute("customInfo");


○ session 값 사용하기

방법 1 : ${info.userId }

            CustomInfo info = (CustomInfo)session.getAttribute("CustomInfo"); 필요

방법 2 : ${sessionScope.customInfo.userId }

CustomInfo info = (CustomInfo)session.getAttribute("CustomInfo"); 필요X

            sessionScope로 바로 불러서 사용하기 때문에


○ body 부분

 로그인O

로그인 X 

 ○ 정보수정 / 로그아웃

 ○ 성적처리(JSP) / 게시판 / 방명록 / 성적처리(Servlet)

 ○ 게시판(Servlet) - 글 작성 가능

 ○ 회원가입 / 로그인

 ○ 게시판 열람만 가능

 ○ 게시판 글 작성시 로그인 필요

${empty sessionScope.customInfo.userId } : session의 customInfo에서 userId의 값이 없으면(비어있으면) 실행

<body>

<c:choose>

<c:when test="${empty sessionScope.customInfo.userId }">

<a href="<%=cp%>/join/created.do" style="text-decoration: none">회원가입</a>

<a href="<%=cp%>/join/login.do" style="text-decoration: none">로그인</a><br/><br/>

</c:when>

<c:otherwise>

<a href="<%=cp%>/join/updated.do" style="text-decoration: none">정보수정</a>

<a href="<%=cp%>/join/logout.do" style="text-decoration: none">로그아웃</a><br/><br/>

</c:otherwise>

</c:choose>


<c:choose>

<c:when test="${empty sessionScope.customInfo.userId }">

<b>로그인 하면 새로운 세상이 보입니다...</b><br/><br/>

</c:when>

<c:otherwise>

${sessionScope.customInfo.userName }님 반갑습니다:)<br/><br/>

</c:otherwise>

</c:choose>


<c:choose>

<c:when test="${empty sessionScope.customInfo.userId }">

1.성적처리(JSP)<br/>

2.게시판<br/>

3.방명록<br/>

4.성적처리(Servlet)<br/>

</c:when>

<c:otherwise>

1.<a href="<%=cp%>/score/list.jsp" style="text-decoration: none">성적처리(JSP)</a><br/>

2.<a href="<%=cp%>/board/list.jsp" style="text-decoration: none">게시판</a><br/>

3.<a href="<%=cp%>/guest/guest.jsp" style="text-decoration: none">방명록</a><br/>

4.<a href="<%=cp%>/sung/list.do" style="text-decoration: none">성적처리(Servlet)</a><br/>

</c:otherwise>

</c:choose>

5.<a href="<%=cp%>/bbs/list.do" style="text-decoration: none">게시판(Servlet)</a><br/>

</body>


결과

○ index.jsp(초기화면) - 로그인X


○ index.jsp(초기화면) - 로그인O


○ 회원가입


○ 로그인


○ 정보수정

○ 1.성적처리(JSP)


○ 2.게시판


○ 3.방명록


○ 4.성적처리(Servlet)


○ 5.게시판(Servlet)


댓글