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;
}
}
UseBeanEx02.jsp : 실행
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!-- scope="request" : request 객체가 살아있는동안 값을 유지. 만약 page라면 page내에서만 유지 -->
<jsp:useBean id="pinfo2" class="mall.PersonalInfo" scope="request" >
<jsp:setProperty name="pinfo2" property="name" value="전효성" />
<jsp:setProperty name="pinfo2" property="gender" value="여" />
<jsp:setProperty name="pinfo2" property="age" value="22" />
</jsp:useBean>
<jsp:forward page="CustomerInfoViewer.jsp"></jsp:forward>
CustomerInfoViewer.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean id="pinfo2" class="mall.PersonalInfo" scope="request" />
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>표준액션 : 자바빈 프로퍼티2</title>
</head>
<body>
이름 : <jsp:getProperty name="pinfo2" property="name" /><br>
성별 : <jsp:getProperty name="pinfo2" property="gender" /><br>
나이 : <jsp:getProperty name="pinfo2" property="age" /><br>
</body>
</html>
'JAVA > JSP & Servlet' 카테고리의 다른 글
표준 액션(standard action) : useBean (property="*") (0) | 2013.03.22 |
---|---|
표준 액션(standard action) : useBean (param) (0) | 2013.03.22 |
표준 액션(standard action) : useBean (0) | 2013.03.22 |
표준 액션(standard action) : forward (0) | 2013.03.22 |
표준 액션(standard action) : Include (0) | 2013.03.22 |