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>
'프로젝트 기반 자바(JAVA) 응용 SW개발자 취업과정 > JSP 활용 연습' 카테고리의 다른 글
게시판 만들기_1 ( list.jsp / view.jsp )MariaDB (0) | 2023.06.15 |
---|---|
List 회원 클릭 시 회원 정보 조회 하기 (0) | 2023.06.13 |
MariaDB활용 테이블 추가(Insert) (0) | 2023.06.12 |
MariaDB활용 테이블 조회(Select) (0) | 2023.06.12 |
매개 변수 다형성_드롭다운 목록 선택_동물에 맞는 메소드 호출 (0) | 2023.06.07 |