para2_exam.html
<!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>Insert title here</title>
</head>
<body>
빈즈로 받게 하기
<form action="para1.jsp" method="post">
<input type="text" name="me">
<input type="submit" >
</form>
</body>
</html>
==================================================================================================================================
para2_exam.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
//String name = request.getParameter("name"); // 이런거 x
%>
<!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>Insert title here</title>
</head>
<body>
폼빈에 등록된 자료 출력해 보기<br/>
<jsp:useBean id="bean" class="pack.FormBean"/>
<!-- <jsp:setProperty property="name" name="bean"/> --> <!-- 이런거 x -->
<jsp:setProperty property="*" name="bean"/> <!-- 넘어오는 데이터를 모두 받게 된다. name으로 자동 맵핑되어 데이터가 setting된다.-->
이름은 <jsp:getProperty property="name" name="bean"/><br/>
국어는 <jsp:getProperty property="kor" name="bean"/><br/>
영어는 <jsp:getProperty property="eng" name="bean"/><br/>
<jsp:useBean id="examProcess" class="pack.ExamProcess" />
<jsp:setProperty property="formBean" name="examProcess" param="bean" />
총점은 <jsp:getProperty property="tot" name="examProcess"/>
평균은 <jsp:getProperty property="avg" name="examProcess"/>
</body>
</html>
==================================================================================================================================
FormBean.java
package pack;
public class FormBean {
private String name;
private int kor,eng;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKor() {
return kor;
}
public void setKor(int kor) {
this.kor = kor;
}
public int getEng() {
return eng;
}
public void setEng(int eng) {
this.eng = eng;
}
}
==================================================================================================================================
'JSP(Java Server Page)' 카테고리의 다른 글
jsp:Bean 태그 사용하기(데이터 다루기) (0) | 2014.03.21 |
---|---|
dbcp객체를 server환경설정으로 다루기(싱글톤아님) (0) | 2014.03.21 |
beans를 사용하여 데이터 주고받기 (0) | 2014.03.21 |
Get방식의 길이 제한에 대한 이야기 (0) | 2014.03.20 |
JSP안의 자바소스 (0) | 2014.03.19 |