Person_java

package jsp0607;

public class Person {
	private String name;
	private String address;
	private String phone;
	private String email;
	private int birthday; // 예) 19880607
	
	
	
	
	@Override
	public String toString() {
		return "Person [name=" + name + ", address=" + address + ", phone=" + phone + ", email=" + email + ", birthday="
				+ birthday + "]";
	}

	public Person() {} // 기본 생성자 필요 
	// 생성자
	public Person(String name, String address, String phone, String email, int birthday) {
		super();
		this.name = name;
		this.address = address;
		this.phone = phone;
		this.email = email;
		this.birthday = birthday;
	}
	
	
	// Getter, Setter
	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 getPhone() {
		return phone;
	}

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

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getBirthday() {
		return birthday;
	}

	public void setBirthday(int birthday) {
		this.birthday = birthday;
	}
	
	
	
	
}

 

 

form_JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="person.jsp">
<a>이름 입력=></a><input type="text" name="name"></br>
<a>주소 입력=></a><input type="text" name="adress"></br>
<a>번호 입력=></a><input type="text" name="phone"></br>
<a>이메일 입력=></a><input type="text" name="email"></br>
<a>생년월일 입력=></a><input type="text" name="day"></br>
<input type="submit">
<input>
</form>
</body>
</html>

 

 

Person_JSP

<%@page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="jsp0607.Person" %>
<%
Person person = new Person();
//person.setName("홍길동");
//System.out.println(person);
String name = request.getParameter("name");
person.setName(name);
String adress = request.getParameter("adress");
person.setAddress(adress);
String phone = request.getParameter("phone");
person.setPhone(phone);
String email = request.getParameter("email");
person.setEmail(email);
String day = request.getParameter("day");
int days = Integer.parseInt(day);
person.setBirthday(days);


%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
out.println(person.getName());
out.println(person.getAddress());
out.println(person.getPhone());
out.println(person.getEmail());
out.println(person.getBirthday());
%>
</body>
</html>

 

+ Recent posts