31-2: Servlet jsp2

jk·2024년 2월 15일
0

kdt 풀스택

목록 보기
60/127



1. jsp로 1단부터 9단까지 나오도록 하시오.

<!-- code -->
<!-- .\WebContent\gugudanAll.jsp -->
<%@ 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>
<%
	final int DAN_MIN = 1;
	final int DAN_MAX = 9;
	StringBuilder print = new StringBuilder();
	for (int i = DAN_MIN; i <= DAN_MAX; i++) {
		for (int j = DAN_MIN; j <= DAN_MAX; j++) {
			print.append(i);
			print.append("x");
			print.append(j);
			print.append("=");
			print.append(i * j);
			%>
			<%=print.toString()%>
			<%
			print.setLength(0);
			%>
			<br>
			<%			
		};
		%>
		<br>
		<%
	};
%>
<a href="gugudanAll.html">BACK</a> 
</body>
</html>



2.five_star.jsp - 아래의 별을 찍으시오

*
**
***
****
*****
 
*****
****
***
**
*
<!-- code -->
<!-- .\WebContent\five_star.jsp -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Five Star</title>
</head>
<body>
<%
	final int ROW_MIN = 1;
	final int ROW_MAX = 5;
	final int COLUMN_MIN = 1;
	final int COLUMN_MAX = 5;
	StringBuilder print = new StringBuilder();
	for (int i = ROW_MIN; i <= ROW_MAX; i++) {
		for (int j = COLUMN_MIN; j <= COLUMN_MAX; j++) {
			if (j <= i) {
				print.append("*");
			};
		};
		%>
		<%=print.toString()%>
		<%print.setLength(0);%>
		<br>
		<%
	};
	%>
	<br>
	<%
	for (int i = ROW_MIN; i <= ROW_MAX; i++) {
		for (int j = COLUMN_MAX; j >= COLUMN_MIN; j--) {
			if (j >= i) {
				print.append("*");
			};
		};
		%>
		<%=print.toString()%>
		<%print.setLength(0);%>
		<br>
		<%
	};
%>
<a href="five_star.html">BACK</a>
</body>
</html>



3. 아래에 대하여 예를 들어 설명하시오.

-지시자
-스크립틀릿
-expression
<!-- directive -->
<%@ ...%>
<!-- scriptlet -->
<% ...%>
<!-- expression -->
<%= ...%>
profile
Brave but clumsy

0개의 댓글