카테고리 없음

[JSP] 현재시간 출력

너래쟁이 2018. 4. 10. 19:52

ServletTest.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<%@page import="java.util.Calendar"%>
<%@ 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>
<%
Calendar c = Calendar.getInstance(); 
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
%>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Servlet title here</title>
</head>
<body>
 
<h1>JSP : 현재시간은 <%=hour %>시 <%=minute %><%=second %> 초 입니다</h1>
 
</body>
</html>
cs