jsp第二次作业

1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<body>
    <%
    Calendar c=Calendar.getInstance();
    int h=c.get(Calendar.HOUR);
    int m=c.get(Calendar.MINUTE);
    int s=c.get(Calendar.SECOND);
    String a="";//java注释
    if(h>=0&&h<=12){
        a="上午好";
    }
    if(h>=13&&h<=17){
        a="下午好";
    }
    if(h>=18&&h<=23){
        a="晚上好";
    }
     %>
     <tr align="center"><td>现在时间是:<%=h %>:<%=m %>:<%=s %>--<%=a %></td></tr>
  </body>

  

 

2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <%int nian=2023; %>
   
  <%
   if(nian%100!=0&&nian%4==0)
   { out.print("是闰年");
  }
 else if(nian%400==0) { out.print("是闰年");
  }
  else
  {
  out.print("2023不是闰年");}
  %>
  </head>
  <body>
 
  </body>
</html>

  

 

3.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!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>
  <%
  for(int i=1;i<=5;i++){ %>
  <hr width="<%=i*100%>px"><%--jsp注释 --%>
 
  <%  }%>
  </body>
</html>

  

posted @ 2022-07-03 21:58  欧阳晨  阅读(2)  评论(0编辑  收藏  举报