본문 바로가기
IT/JSP

[JSP]자바빈 02

by dya0 2019. 5. 14.

클라이언트에서 name이라는 이름의 파라미터 값을 name 프로퍼티에 할당 (저장)하겠다는 의미다.
proprty와 param 속성의 값이 다른 경우 param 속성을 생략 가능하다.

property의 속성 값을 "*"로 지정하면 각각의 프로퍼티의 값을 같은 이름을 갖는 파라미터의 값으로 설정한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@page import="javaBean.BeanTest"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
</head>
<body>
<form action = "BeanTest1.jsp" method = "post">
이름 : <input type = "text" name ="name">
<br>
<input type = "submit" value = "전송">
</form>
</body>
</html>
Colored by Color Scripter

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<%@page import="javaBean.BeanTest"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <%request.setCharacterEncoding("euc-kr"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>자바빈을 스크립트 요소로 접근한 경우</title>
</head>
<body>
<h1> 자바빈 예제 </h1>
<jsp:useBean id = "beanTest" class = "javaBean.BeanTest"/>
<jsp:setProperty name = "beanTest" property = "name" param = "name"/>
 
<h3><jsp:getProperty name ="beanTest" property = "name"/></h3>
</body>
</html>
Colored by Color Scripter

BeanTest1

결과전송

'IT > JSP' 카테고리의 다른 글

[JSP]context.xml  (0) 2019.05.15
[JSP]커넥션 풀(Connection Pool)  (0) 2019.05.15
[JSP]context  (0) 2019.05.14
[JSP]자바빈 JAVABEAN  (0) 2019.05.14
[JSP]include로 화면 구현하기  (0) 2019.05.14