<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.Calendar" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Calendar sDay = Calendar.getInstance();
Calendar eDay = Calendar.getInstance();
StringBuffer sb = new StringBuffer();
int year = 2009;
int month = 5;
sDay.set(year, month-1, 1);
eDay.set(year, month, 0);
sb.append("year :'" +year +"<br>");
sb.append("month :" +month +"<br>");
sb.append("- :" +eDay.get(Calendar.DATE) +"<br>");
sb.append("sDay :" +sDay.get(Calendar.DATE) +"<br>");
sb.append("eDay :" +eDay.get(Calendar.DATE) +"<br>");
sb.append("Day of week :" +sDay.get(Calendar.DAY_OF_WEEK) +"<p>");
sb.append(" " +year +"년 " +month +"월"+"<br>");
sb.append("<table border='1'>");
sb.append("<tr>");
sb.append("<td>" +"일" +"</td>");
sb.append("<td>" +"월" +"</td>");
sb.append("<td>" +"화" +"</td>");
sb.append("<td>" +"수" +"</td>");
sb.append("<td>" +"목" +"</td>");
sb.append("<td>" +"금" +"</td>");
sb.append("<td>" +"토" +"</td>");
sb.append("</tr>");
sb.append("<tr>");
for(int i=1; i<sDay.get(Calendar.DAY_OF_WEEK); i++){
sb.append("<td>");
sb.append("");
sb.append("</td>");
}
for(int i=sDay.get(Calendar.DATE), n=sDay.get(Calendar.DAY_OF_WEEK); i<=eDay.get(Calendar.DATE); i++, n++){
sb.append("<td>");
if(eDay.get(Calendar.DATE) == i){
sb.append("<td bgcolor='yellow'>");
}
sb.append((i<10)?" 0"+i : " "+i);
if(n%7==0) sb.append("</td></tr>");
}
sb.append("</table>");
%>
<%= sb %>
</body>
</html>
<%@page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%!
private StringBuffer getGugudan(int dan) {
StringBuffer result = new StringBuffer();
result.append("<table border='0' cellpadding='2' cellspacing='0'>");
result.append("<tr>");
result.append("<td align='center'>" + dan + "단</td>");
result.append("</tr>");
for(int row=1 ; row<10 ; row++) {
result.append("<tr>");
result.append("<td align='center'>" + dan + "X" + row + "=" + (dan*row) + "</td>");
result.append("</tr>");
}
result.append("</table>");
return result;
}
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
</head>
<body>
<table border='1' cellpadding='2' cellspacing='0' bordercolordark='#ffffff' bordercolorlight='#000000'>
<%
for(int i=1 ; i<10 ; i++) {
if(i%3 == 1) {
out.println("<tr>");
}
out.println("<td width='100' align='center'>" + getGugudan(i).toString() + "</td>");
if(i%3 == 0) {
out.println("</tr>");
}
}
%>
</table>
</body>
</html>
pageEncoding="UTF-8"%>
<%@ page import="java.util.Calendar" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Calendar sDay = Calendar.getInstance();
Calendar eDay = Calendar.getInstance();
StringBuffer sb = new StringBuffer();
int year = 2009;
int month = 5;
sDay.set(year, month-1, 1);
eDay.set(year, month, 0);
sb.append("year :'" +year +"<br>");
sb.append("month :" +month +"<br>");
sb.append("- :" +eDay.get(Calendar.DATE) +"<br>");
sb.append("sDay :" +sDay.get(Calendar.DATE) +"<br>");
sb.append("eDay :" +eDay.get(Calendar.DATE) +"<br>");
sb.append("Day of week :" +sDay.get(Calendar.DAY_OF_WEEK) +"<p>");
sb.append(" " +year +"년 " +month +"월"+"<br>");
sb.append("<table border='1'>");
sb.append("<tr>");
sb.append("<td>" +"일" +"</td>");
sb.append("<td>" +"월" +"</td>");
sb.append("<td>" +"화" +"</td>");
sb.append("<td>" +"수" +"</td>");
sb.append("<td>" +"목" +"</td>");
sb.append("<td>" +"금" +"</td>");
sb.append("<td>" +"토" +"</td>");
sb.append("</tr>");
sb.append("<tr>");
for(int i=1; i<sDay.get(Calendar.DAY_OF_WEEK); i++){
sb.append("<td>");
sb.append("");
sb.append("</td>");
}
for(int i=sDay.get(Calendar.DATE), n=sDay.get(Calendar.DAY_OF_WEEK); i<=eDay.get(Calendar.DATE); i++, n++){
sb.append("<td>");
if(eDay.get(Calendar.DATE) == i){
sb.append("<td bgcolor='yellow'>");
}
sb.append((i<10)?" 0"+i : " "+i);
if(n%7==0) sb.append("</td></tr>");
}
sb.append("</table>");
%>
<%= sb %>
</body>
</html>
<%!
private StringBuffer getGugudan(int dan) {
StringBuffer result = new StringBuffer();
result.append("<table border='0' cellpadding='2' cellspacing='0'>");
result.append("<tr>");
result.append("<td align='center'>" + dan + "단</td>");
result.append("</tr>");
for(int row=1 ; row<10 ; row++) {
result.append("<tr>");
result.append("<td align='center'>" + dan + "X" + row + "=" + (dan*row) + "</td>");
result.append("</tr>");
}
result.append("</table>");
return result;
}
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
</head>
<body>
<table border='1' cellpadding='2' cellspacing='0' bordercolordark='#ffffff' bordercolorlight='#000000'>
<%
for(int i=1 ; i<10 ; i++) {
if(i%3 == 1) {
out.println("<tr>");
}
out.println("<td width='100' align='center'>" + getGugudan(i).toString() + "</td>");
if(i%3 == 0) {
out.println("</tr>");
}
}
%>
</table>
</body>
</html>
'Study > Programming' 카테고리의 다른 글
JSP submit get/post전송 (0) | 2009.05.28 |
---|---|
JSP 서버이름, 클라이언트ip (0) | 2009.05.28 |
JSP DB연동 (0) | 2009.05.27 |
JSP 날짜 구하기 (0) | 2009.05.27 |
JSP 구구단 (0) | 2009.05.27 |