티스토리 뷰

코딩/JSP

[8주 5일차] 액션 태그

ehzim 2023. 12. 1. 13:46

 

 

 

 

 

ex) useBean 액션 태그에 [예제 4-7]에서 생성한 자바빈즈 person으로 아이디와 이름을 설정하여 출력

4-8

<%@ 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>
	<jsp:useBean id="person" class="dao.person" scope="request"></jsp:useBean>
	<p>아이디 : <%=person.getId() %>
	<p>이 름 : <%=person.getName() %>
		<%
			person.setId(20182005);
			person.setName("홍길동");
		%>
		<jsp:include page="useBean03.jsp"></jsp:include>
</body>
</html>

 

 

 

ex) setProperty 액션 태그에 자바빈즈 person을 아이디와 이름을 설명하여 출력

4-9

<%@ 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>
	<jsp:useBean id="person" class="dao.person" scope="request"></jsp:useBean>
	<jsp:setProperty property="id" name="person" value="20182005"/>
	<jsp:setProperty property="name" name="person" value="홍길동" />
	<p>아이디 : <%=person.getId() %>
	<p>이 름 : <%=person.getName() %>
</body>
</html>

 

 

 

ex) getProperty 액션 태그에 자바빈즈 person을 이용하여 아이디와 이름을 가져와 출력

4-10

<%@ 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>
	<jsp:useBean id="person" class="dao.person" scope="request"></jsp:useBean>
	<p> 아이디 : <jsp:getProperty property="id" name="person"/>
	<p> 이 름 : <jsp:getProperty property="name" name="person"/>
</body>
</html>

 

 

 

 

 

ex) getProperty 액션 태그에 자바빈즈 person을 이용하여 아이디와 이름을 전달받아 출력

 

4-11

<%@ 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>
	<jsp:useBean id="person" class="dao.person"></jsp:useBean>
	<jsp:setProperty property="id" name="person" value="20182005"/>
	<jsp:setProperty property="name" name="person" value="홍길동"/>
	<p> 아이디 : <jsp:getProperty property="id" name="person"/>
	<p> 이 름 : <jsp:getProperty property="name" name="person"/>
</body>
</html>

 

 

 

 

'코딩 > JSP' 카테고리의 다른 글

[9주 1일차] 내장 객체  (0) 2023.12.04
웹쇼핑몰  (0) 2023.12.01
[8주 4일차] 액션 태그  (1) 2023.11.30
[8주 3일차] 디렉티브 태그  (0) 2023.11.29
[8주 3일차] 스크립트 태그  (0) 2023.11.29
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday