Bean alkalmazása JSP oldalon

<?xml version="1.0" encoding="utf-8" ?>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Bean objektum a JSP lapon</title>
</head>
<body>
<%
Double db= (Double) (Math.random() * 20);
pageContext.setAttribute("random", db, PageContext.PAGE_SCOPE);
%>
A generált véletlen szám: <c:out value = "${random}"/>
<c:if test="${pageScope.random < 10}">
<c:set var="randomFailed" value="true"/>
</c:if>
 
<c:choose>
<c:when test="${pageScope.randomFailed == true}">
Kivételesen kicsi szám. ${random}
</c:when>
<c:otherwise>
10-nél nagyobb szám. ${random}
</c:otherwise>
</c:choose>
</body>
</html>