Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter01 : attribute 본문

JSP/EL

chapter01 : attribute

GAWON 2023. 5. 24. 09:22
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	//1~100값의 총 합 출력
	int total = 0;
	for(int i=0; i<101; i++){
		total +=i;
	}						
							// key , value	
	pageContext.setAttribute("TOTAL", total);//pageContext속성에 setAttribute저장
%>    
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>1~100사이의 모든 정수의 합은<%=total %></h1> <!-- 표현식 -->
	<h1>1~100사이의 모든 정수의 합은<%=pageContext.getAttribute("TOTAL")%></h1>
	<h1>1~100사이의 모든 정수의 합은${TOTAL }</h1>		<!-- 속성명이TOTAL이라면 그대로 가져다 쓸수있다(가독성이좋다) -->
</body>
</html>

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

chapter05 : EL1 / EL2  (0) 2023.05.24
chapter04 : EL1 / EL2  (0) 2023.05.24
chapter03 : EL1 / EL2  (0) 2023.05.24
chapter02 : EL_overview  (0) 2023.05.24
EL  (0) 2023.05.24