JSP第二次作业

<body>
    <%
/*1.p39   实验2 显示当前时间,并输出上午(0-12)好,下午好(13-17),晚上好(18-23)*/
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>

 

 

 

 

 

 

<body>
  <%
/*2. 使用声明方法,在页面调用该方法,判断2023是不是闰年*/
  int y=2013;
  String a="";
  if(y%100!=0&&y%4==0||y%400==0){
  a="是闰年";
  }else{
  a="不是闰年";<!--html注释-->
  }
   %>
   <tr align="center"><td>2013年<%=a %></td></tr>
  </body>

 

 

 

<%@ 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>
  <%
for(int i=1;i<=5;i++){
%><hr width="<%=i*100%>px" color="red">
<% } %>
  </body>
</html>

 

posted @ 2022-03-20 18:54  Vending  阅读(13)  评论(0编辑  收藏  举报