JSP 2일차 UseBean

form.jsp

<!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>Introduce GUI</title>
</head>
<body>

<form action="RequestTest.jsp" method="post">
<table cellpadding="5">
<tr>
<th>ID</th>
<th><input type="text" name="id" size="16"></th>
</tr>
<tr>
<th>P/W</th>
<th><input type="password" name="password" size="16"></th>
<th>Name</th>
<th><input type="text" name="name" size="16"></th>
</tr>
<tr>
<th>Gender</th>
<th><input type="radio" name="gender" value="male"> male
<input type="radio" name="gender" value="female"> female</th>
<th>Hobby</th>
<th><input type="checkbox" name="hobby" value="baseball">baseball
<input type="checkbox" name="hobby" value="soccer">soccer</th>
</tr>
<tr>
<th>Phone</th>
<th colspan="3">
<select name="first_phone">
<option value="010">010</option>
<option value="011">011</option>
<option value="016">016</option>
<option value="019">019</option>
</select>-
<input type="text" name="middle_phone" size="8">-
<input type="text" name="last_phone" size="8"></th>
<tr>
<th>etc</th>
<th colspan="3"><textarea name="etc" rows="3" cols="50"></textarea></th>
<tr>
<th colspan="4">
<center>
<input type="submit" value="Send">
<input type="submit" value="Cancel">
</center>
</th>
</tr>
</table>
</form>

</body>
</html>

UseBean.jsp

<%@page import="member.MemberBean"%>
<%@ 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>

<h2> useBean </h2>

<jsp:useBean id="mbean" class="member.MemberBean">
</jsp:useBean>

id <%=mbean.getId() %>

<%
MemberBean mbean2 = new MemberBean();
%>
<br>id <%=mbean2.getId() %>

</body>
</html>

MemberBean.java

package member;

public class MemberBean
{
private String id = "test";
private String password;
private String gender;
private String hobby;
private String phone;
private String etc;

public String getId()
{
return id;
}

public void setId(String id)
{
this.id = id;
}

public String getPassword()
{
return password;
}

public void setPassword(String password)
{
this.password = password;
}

public String getGender()
{
return gender;
}

public void setGender(String gender)
{
this.gender = gender;
}

public String getHobby()
{
return hobby;
}

public void setHobby(String hobby)
{
this.hobby = hobby;
}

public String getPhone()
{
return phone;
}

public void setPhone(String phone)
{
this.phone = phone;
}

public String getEtc()
{
return etc;
}

public void setEtc(String etc)
{
this.etc = etc;
}
}


result)


댓글 없음: