티스토리 뷰

Web/JSP

[JSP] jsp로 구구단 만들기

쩨리쩨리 2018. 4. 11. 15:24
반응형

* JSP 파일에서 HTML 문법을 이용해 구구단을 만들어보자

 

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
    <center>
        <h1>구구단</h1>
        <table border=1 cellpadding=0 cellspacing=2 width=500 >
            <%
                for (int i = 0; i < 10; i++) {
                    %>
            <tr aligncenter >
                <%  
                    for (int j = 1; j < 10; j++) {
                        %>
                <% 
                        if(i ==0 && j==1){
                            %><td aligncenter bgcolor=pink></td>
                <%
                        }else if(i==0){
                            %>
                <td bgcolor=pink><%= j+ "단" %></td>
                <%
                        } else if(j==1){
                            %>
                <td width = 700 aligncenter bgcolor=pink><%= i %></td>
                <%
                        }else {
                            %>
                <td aligncenter><%= j+"X"+i+"="+j*%></td>
                <% 
                        }%>
                <%
                    }
                    %>
            </tr>
            <%
                }
            %>
        </table>
    </center>
</body>
</html>
cs

 

 

 

 

 

 

* 완성 모습

 

 

 

 

반응형
댓글
공지사항