Jam's story
[JSP]자바빈즈 본문
ex03_02.jsp
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<title>2022. 6. 20.-오전 11:37:31</title>
</head>
<body>
<h3>ex03_02</h3>
<pre>
꼭 지킬것: id 속성값은 memberInfo 클래스의 필드명과 반드시 동일하게 설정
</pre>
<form action="ex03_04.jsp" method="get"></form>
<table border="1" style="width:400px">
<tr>
<td>아이디:</td>
<td><input type="text" name="id" value="admin"></td>
</tr>
<tr>
<td>이름:</td>
<td><input type="text" name="name" value="관리자"></td>
</tr>
<tr>
<td>패스워드:</td>
<td><input type="password" name="passwd" value="1234"></td>
</tr>
<tr>
<td>이메일:</td>
<td><input type="text" name="email" value="admin@naver.com"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit">
<input type="result">
</td>
</tr>
</table>
</body>
</html>
ex03_03.jsp
<%@page import="java.util.Date"%>
<%@page import="days05.MemberInfo"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="">
<style>
</style>
<script>
$(document).ready(function (){
});
</script>
</head>
<body>
<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String passwd = request.getParameter("passwd");
String email = request.getParameter("email");
MemberInfo info = new MemberInfo();
info.setId(id);
info.setName(name);
info.setPasswd(passwd);
info.setRegisterDate(new Date()); //등록일은 받아오지 않고 현재로
info.setEmail(email);
%>
<h3>멤버 정보 출력</h3>
아이디 : <%=info.getId() %><br>
이름 : <%=info.getName() %><br>
비밀번호 : <%=info.getPasswd() %><br>
등록일 : <%=info.getRegisterDate() %><br>
이메일 : <%=info.getEmail() %><br>
</body>
</html>
ex03_04.jsp
<%@page import="java.util.Date"%>
<%@page import="days05.MemberInfo"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>2022.06.20 11:45:25</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
</head>
<body>
<h3>ex03_04.jsp</h3>
<%
//1.파리미터 - 변수저장
String id = request.getParameter("id");
String name = request.getParameter("name");
String passwd = request.getParameter("passwd");
String email = request.getParameter("email");
%>
<jsp:useBean id="info" class="days05.MemberInfo"></jsp:useBean>
<jsp:setProperty property="id" name="info" value='<%= request.getParameter("id") %>'/>
<jsp:setProperty property="name" name="info" value='<%= request.getParameter("name") %>'/>
<jsp:setProperty property="passwd" name="info" value='<%= request.getParameter("passwd") %>'/>
<jsp:setProperty property="registerDate" name="info" value='<%= new Date() %>'/>
<jsp:setProperty property="email" name="info" value='<%= request.getParameter("email") %>'/>
<h3>MemberInfo 정보 출력</h3>
<!-- //3.자바 빈즈 정보 출력 -->
아이디: <%= info.getId() %><br>
이름: <%= info.getName() %><br>
비밀번호: <%= info.getPasswd() %><br>
등록일: <%= info.getRegisterDate() %><br>
이메일: <%= info.getEmail() %><br>
</body>
</html>
ex03_05.jsp
'JSP' 카테고리의 다른 글
[JSP] 클라이언트와 대화 - 쿠키 (0) | 2022.06.21 |
---|---|
[JSP] 게시판 - 목록, 글쓰기 기능 , 페이징 처리 (0) | 2022.06.20 |
[JSP] 페이지 모듈화와 요청 흐름 ->공통적인 부분 처리 (0) | 2022.06.20 |
[JSP] 에러처리 (0) | 2022.06.20 |
[JSP] 파라미터 처리하는 메소드 (0) | 2022.06.20 |