2013년 7월 18일 목요일

(130718) 19일차 Login.jsp, LoginProc.jsp (코어 태그, Bean 클래스 사용하기)

 - Login.jsp 소스
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<center>
<form action = "LoginProc.jsp" method = "post">
아이디 : <input type = "texT" name = "id"><br><br>
비밀번호 : <input type = "password" name = "pass"><br><br>
<input type = "submit" value = "로그인"><br><br>
</form>
</center>
</body>
</html>


 - LoginProc.jsp 소스
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>

<!-- <c:set var="id" value="${param.id}"/> 
<c:set var="pass" value="${param.pass}"/> -->

<% request.setCharacterEncoding("euc-kr"); %>
  <!-- 빈클래스 생성 -->
  <jsp:useBean id = "bean" class = "Jtls.LoginBean"></jsp:useBean>
  <!-- 빈클래스에 데이터를 추가 -->
    <jsp:setProperty property = "*" name = "bean"/>
   
<c:set var="id" value="${bean.getId()}"/> 

당신의 아이디는 <c:out value="${id}"/> 이고 <br>
<!-- c:set을 꼭 사용할 필요는 없다. -->
당신의 비밀번호는 <c:out value="${bean.getPass()}"/> 이고

</body>
</html>


 - 결과