1. JSTL에서 Java Bean 이용
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core-rt" prefix="c-rt" %>
<html>
<head>
<title>If Caseless</title>
</head>
<body>
<c:set var="str" value="jStL" />
<jsp:useBean id="str" type="java.lang.String" />
<c-rt:if test='<%=str.equalsIgnoreCase("JSTL")%>'> They are
equal</c-rt:if>
</body>
</html>
2. 하나 이상의 Bean이용
3. 빈과 Output에 잘될 폼 데이터 설정
3.1 index.jsp
<html>
<head><title>Create Person</title></head>
<body>
<h1>Enter your details</h1>
<form action="listPageParameters.jsp" method="post">
<table>
<tr><td>First name:</td> <td><input type="text" name="firstName" /></td></tr>
<tr><td>Last name:</td> <td><input type="text" name="lastName" /></td></tr>
<tr><td>Age:</td> <td><input type="text" name="age" /></td></tr>
</table>
<input type="submit" value="Submit details" />
</form>
</body>
</html>
3.2 listPageParameters.jsp 작성
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head><title> Display details</title></head>
<body>
<h1>Your details (or, the details that you entered!)</h1>
<table>
<tr><td>First name</td>
<td><c:out value="${param.firstName}" /></td>
</tr>
<tr><td>Last name</td>
<td><c:out value="${param.lastName}" /></td>
</tr>
<tr><td>Age</td>
<td><c:out value="${param.age}" /></td>
</tr>
<%-- The following two values are not passed from the HTML form
and are present to show the syntax for specifying default
values --%>
<tr><td>Partner's name</td>
<td><c:out value="${param.partnerName}" default="Unknown name" /></td>
</tr>
<tr><td>Partner's age</td>
<td><c:out value="${param.partnerAge}">
Unknown age
</c:out>
</td>
</tr>
</table>
</body>
</html>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core-rt" prefix="c-rt" %>
<html>
<head>
<title>If Caseless</title>
</head>
<body>
<c:set var="str" value="jStL" />
<jsp:useBean id="str" type="java.lang.String" />
<c-rt:if test='<%=str.equalsIgnoreCase("JSTL")%>'> They are
equal</c-rt:if>
</body>
</html>
2. 하나 이상의 Bean이용
2.1 Bid.java 빈 작성 | |
2.2 Bidder.java 빈 작성 | |
| |
2.3 BidError.java 자바 빈 작성 | |
| |
| |
| |
|
3.1 index.jsp
<html>
<head><title>Create Person</title></head>
<body>
<h1>Enter your details</h1>
<form action="listPageParameters.jsp" method="post">
<table>
<tr><td>First name:</td> <td><input type="text" name="firstName" /></td></tr>
<tr><td>Last name:</td> <td><input type="text" name="lastName" /></td></tr>
<tr><td>Age:</td> <td><input type="text" name="age" /></td></tr>
</table>
<input type="submit" value="Submit details" />
</form>
</body>
</html>
3.2 listPageParameters.jsp 작성
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head><title> Display details</title></head>
<body>
<h1>Your details (or, the details that you entered!)</h1>
<table>
<tr><td>First name</td>
<td><c:out value="${param.firstName}" /></td>
</tr>
<tr><td>Last name</td>
<td><c:out value="${param.lastName}" /></td>
</tr>
<tr><td>Age</td>
<td><c:out value="${param.age}" /></td>
</tr>
<%-- The following two values are not passed from the HTML form
and are present to show the syntax for specifying default
values --%>
<tr><td>Partner's name</td>
<td><c:out value="${param.partnerName}" default="Unknown name" /></td>
</tr>
<tr><td>Partner's age</td>
<td><c:out value="${param.partnerAge}">
Unknown age
</c:out>
</td>
</tr>
</table>
</body>
</html>
'WEB_Programming > JSTL' 카테고리의 다른 글
11. JSTL Cookie 처리 (0) | 2008.06.20 |
---|---|
10. JSTL의 Scope (0) | 2008.06.20 |
8. JSTL Set (0) | 2008.06.20 |
7. JSTL Collection 예제 (0) | 2008.06.20 |
6. JSTL foreach 문 처리 (0) | 2008.06.20 |