PersonalInfo.java
package mall;
public class PersonalInfo {
private String name;
private char gender;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public char getgender() {
return gender;
}
public void setgender(char gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!-- HTML 밖에 써주면 더 보기 편함 :) -->
<jsp:useBean id="pinfo" class="mall.PersonalInfo" />
<jsp:setProperty name="pinfo" property="name" value="이종표" />
<jsp:setProperty name="pinfo" property="gender" value="남" />
<jsp:setProperty name="pinfo" property="age" value="28" />
<jsp:useBean id="pinfo2" class="mall.PersonalInfo" >
<jsp:setProperty name="pinfo2" property="name" value="전효성" />
<jsp:setProperty name="pinfo2" property="gender" value="여" />
<jsp:setProperty name="pinfo2" property="age" value="22" />
</jsp:useBean>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>표준액션 : 자바빈 프로퍼티</title>
</head>
<body>
이름 : <jsp:getProperty name="pinfo" property="name" /><br>
성별 : <jsp:getProperty name="pinfo" property="gender" /><br>
나이 : <jsp:getProperty name="pinfo" property="age" /><br>
<br>
이름 : <jsp:getProperty name="pinfo2" property="name" /><br>
성별 : <jsp:getProperty name="pinfo2" property="gender" /><br>
나이 : <jsp:getProperty name="pinfo2" property="age" /><br>
<br>
<%
out.println(pinfo2.getName() + "<br/>");
out.println(pinfo2.getgender() + "<br/>");
out.println(pinfo2.getAge() + "<br/>");
/* jsp:useBean => 객체화 됨 */
%>
</body>
</html>
'JAVA > JSP & Servlet' 카테고리의 다른 글
표준 액션(standard action) : useBean (param) (0) | 2013.03.22 |
---|---|
표준 액션(standard action) : useBean (scope) (0) | 2013.03.22 |
표준 액션(standard action) : forward (0) | 2013.03.22 |
표준 액션(standard action) : Include (0) | 2013.03.22 |
expression language 태그라이브러리(TLD) [직접 작성한 메서드 호출] (0) | 2013.03.22 |