다음과 같이 표를 그리기

- JSP 이용해서 제작

- 선언, 표현식, 스크립트릿 등 이용하

 

 

 

 

 

 

 

 

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
<%@ 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 charset="EUC-KR">
<title>구구단</title>
</head>
 
<body>
<center>
    <table border="1px solid" width="500px">
        
    <%!
    private String str = "";
    private String getGo(){
        for(int i=0;i<10;i++){
            str += "<tr><td>"+i+"</td>";
            if(i == 0){
                for(int j=2;j<10;j++){
                    str += "<td>"+j+"단"+"</td>";
                }
            }
            else {
                for(int j=2;j<10;j++){
                    str += "<td>"+j+"*"+i+"="+ (i*j) +"</td>";
                }
                str += "</td></tr>";
            }
        }return str;
    }
    
    %>    <%=getGo() %>
    </table>
</center>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
 

'Servlet & JSP' 카테고리의 다른 글

JSP 예제_쿠키  (0) 2019.06.21
JSP 예제_request 이용한 페이지 값 전달  (0) 2019.06.21
JSP 선언, 표현식, 스크립트릿  (0) 2019.06.21
액션(ACTION)  (0) 2019.06.21
JSP 예제_errorPage, isErrorPage  (0) 2019.06.20

+ Recent posts