스크립트

/JSP_Base/WebContent/base.jsp:
<!-- JSP  -->
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
<!--   -->
<%!
	int i =1; //  
	//  , , java 
	public void print() {
	}
	/*
		 
	*/
	public String convertDateToString(String pattern,Date crrentDate) {
		//  
		SimpleDateFormat fmt = new SimpleDateFormat(pattern);
		
		return fmt.format(crrentDate);
	}
%>
<!--   -->
<%
	int i =2;
%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	
	<%
		SimpleDateFormat fmt = new SimpleDateFormat("yyyy MM dd ");
	%>
	<!--   -->
	<%=fmt.format(new Date()) %>
	<!--   -->
	<%=convertDateToString("yyyy/MM/dd", new Date()) %>
	<%=convertDateToString("yyyy-MM-dd HH:mm:ss", new Date()) %>
</body>
</html>

/JSP_Base/WebContent/homework.jsp:
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%--  1 --%>
	<%
		//  List 
		List<String> lst = new ArrayList<String>();
		for(int i=1;i<11;i++) {
			lst.add(" "+i+" ");
		}
		
		out.print(" <br/>");
		
		//  
		for(String value : lst) {
			out.print(value+"<br/>");
		}
	%>
	<br/>
	<%--  2( ) --%>
	<%
		//  
		String[] names = {" "," "," "};
		//  
		int[] scores = {60,70,85};
		//  out.print();
		for(int i = 0; i<names.length ; i++) {
			out.print(names[i]+":&nbsp;&nbsp;"+scores[i]+" <br/>");
		}
	%>
</body>
</html>

***번호 생일 캡처:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String idcard = "500225198812121814";
		String id = idcard.substring(6, 14);
		//  
		String year = id.substring(0,4);
		//  
		String month = id.substring(4,6);
		//  
		String day = id.substring(6,8);
		
		String date = year+"-"+month+"-"+day;
		
		out.print(" :"+date);
	%>
</body>
</html>

좋은 웹페이지 즐겨찾기