%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="<http://java.sun.com/jsp/jstl/core>" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ch05_choose.jsp</title>
</head>
<body>
<h1>choose</h1>
<%--
# <c:choose>
- <c:choose>
<c:when test="조건식_a"> 실행 내용 <c:when>
<c:when test="조건식_b"> 실행 내용 <c:when>
.....
<c:otherwise> 실행 내용 </c:otherwise>
</c:choose>
--%>
<c:set var="age" value="18"/>
<h2>
나이 : ${age} 세 <br>
<c:choose>
<c:when test="${age >= 20 }">성인 </c:when>
<c:when test="${age >= 17}">고등학생</c:when>
<c:when test="${age >= 14}">중학생</c:when>
<c:when test="${age >= 8}">초등학생</c:when>
<c:otherwise>어린이</c:otherwise>
</c:choose>
</h2>
<c:set var="korean" value="${param.korean}"/>
<c:set var="english" value="${param.english}"/>
<c:set var="math" value="${param.math}"/>
<h2>과목 성적</h2>
<c:if test="${not(empty param.korean or empty param.english or empty param.math)}">
<c:set var="tot" value="${param.korean + param.english + param.math}"/>
<c:set var="avg" value="${tot/3}"/>
<c:choose>
<c:when test="${avg >= 90 }"><c:set var="grade" value="A"/></c:when>
<c:when test="${avg >= 80 }"> <c:set var="grade" value="B"/></c:when>
<c:when test="${avg >= 70 }"><c:set var="grade" value="C"/></c:when>
<c:when test="${avg >= 60 }"><c:set var="grade" value="D"/></c:when>
<c:otherwise><c:set var="grade" value="F"/></c:otherwise>
</c:choose>
<p> 총점 : ${tot}</p>
<p> 평균 : ${avg}</p>
<p> 학점 : ${grade}</p>
</c:if>
</body>
</html>