第二次jsp作业

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">	
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <br>
   <%
    	Date date = new Date();
		int hour = date.getHours();
		int minute = date.getMinutes();
		int second = date.getSeconds();
		out.print("当前的时间是" + hour + ":" + minute + ":" + second + "<br>");
		if (hour >= 0 && hour <= 12) {
			out.print("上午好!");
		} else if (hour > 12 && hour <= 17) {
			out.print("中午好!");
		} else if (hour >= 13 && hour <= 18) {
			out.print("下午好!");
		} else if (hour > 18 && hour <= 23) {
			out.print("晚上好!");
		}
    %>
  </body>
</html>

  

 

 

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">	
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <br>
   <%! 
	public static String nian(int year) {
		if (year % 4 == 0 || year % 100 != 0 && year % 400 == 0) {
        	return "闰年";
		}
		return "不是闰年";
		}
    %>
    
    <%
       out.print(nian(2001)); %>
  </body>
</html>

  

 

 

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">	
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <br>
   <%-- 
	public static String nian(int year) {
		if (year % 4 == 0 || year % 100 != 0 && year % 400 == 0) {
        	return "闰年";
		}
		return "不是闰年";
		}
    --%>
    
    <%
       for (int i = 1; i <= 21; i++) {
	%>
	<hr width="<%=i * 100%>px" size="<%=i%>" color="blue">
	<%
		} %>
  </body>
</html>

 

 

  

posted on 2022-03-18 20:42  不顾倾世、只倾她一  阅读(11)  评论(0编辑  收藏  举报

导航