day03_bean1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="people" scope="request" class="util.People"  >
</jsp:useBean>   
<!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=UTF-8">
<title>자바 빈즈</title>
</head>
<body>
	jsp:useBean 에서 id="people"이라는 
	객체를 생성한 것과 같습니다.
	 
	<%   people.setName("자바빈즈"); 
		   people.setAge("30");
		   people.setAddress("서울");
	%>
	
	만든 객체를 scope="request" 범위내에서 사용가능합니다
	<br/><br/>
	이름 : <%=people.getName() %> <br/>
	나이 : <%=people.getAge() %> <br/>
	주소 : <%=people.getAddress() %> <br/>
</body>
</html>



People.java
package util;

public class People {
	private String name;
	private String address;
	private String age;
	
	public People(String name, String address, String age) {
		super();
		this.name = name;
		this.address = address;
		this.age = age;
	}

	public People() {		
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getAddress() {
		return address;
	}


	public void setAddress(String address) {
		this.address = address;
	}


	public String getAge() {
		return age;
	}


	public void setAge(String age) {
		this.age = age;
	}
}




'JSP > 2012.04강의(MySQL)' 카테고리의 다른 글

4일차 JDBC연결  (0) 2012.05.24
3일차 tomcat plugin for eclipse  (0) 2012.05.23
3일차 로그인  (0) 2012.05.23
3일차 Cookie  (0) 2012.05.23
3일차 error화면 만들기  (0) 2012.05.23

+ Recent posts