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

chapter02 : script_element 본문

JSP

chapter02 : script_element

GAWON 2023. 5. 22. 09:18
<%@ 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>
	<h2>0~9 사이에 모든 정수 출력하기</h2>
	<%for(int i=0; i<10; i++){%>
			i <%--문자열 출력 --%>
	
	<%}%>
	
	<h2>0~9 사이에 모든 정수 출력하기</h2>
	<%for(int i=0; i<10; i++){%>
			<%=i %>
	
	<%}%>
	
	<h2>1~100 사이의 모든 정수의 합계를 구해서 출력하기</h2>

	<%
	int total = 0;
	for(int i=1; i<101; i++){
		total += i;
	}
		
	%>
	1~100 사이의 합 = <%=total %>
	
	<h2>1~100사이의 모든 짝수를 합계를 리턴하는 even() 메소드</h2>
	
	<%!
		public int even(){
		int evenSum = 0;
		for(int i=1; i <101; i++){
			if(i % 2 == 0){
			evenSum += i;
			}
		}
		return evenSum;
	}
	
	%>
	1~100 사이의 모든 짝수의 합=<%=even()%>
	
	<h2>1~100사이의 모든 홀수의 합계를 리턴하는 odd() 메소드</h2>
	<%!
		public int odd(){
		int oddSum = 0;
		for(int i=1; i <101; i++){
			if(i % 2 == 0){
			oddSum += i;
			}
		}
	
		return oddSum;
	}
	
	%>
	1~100 사이의 모든 홀수의 합 = <%=odd()%>

</body>
</html>

'JSP' 카테고리의 다른 글

JSP.txt  (0) 2023.05.22
chapter02 : page  (0) 2023.05.22
chapter03 : request  (0) 2023.05.22
chapter04 : 01_send  (0) 2023.05.22
chapter04 : 02_receive  (0) 2023.05.22