jsp第二次作业

<%Calendar c=Calendar.getInstance();
int hour=c.get(Calendar.HOUR);
System.out.println(hour); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <% 
   if(hour>=0&&hour<=12)
   { out.print("现在是"+hour+"上午好"); 
  } 
  else if(hour>=13&&hour<=17){
  out.print("现在是"+hour+"中午好");}
  else
  {
  out.print("现在是"+hour+"下午好");}
  %>
  </head>
  <body>

  </body>
</html>

  

 

2. 使用声明方法,在页面调用该方法,判断2023是不是闰年
闰年:能被4整除但不能被100整除或者能被400整除

 

 

<%@ 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("不是闰年");}
  %>
  </head>
  <body>

  </body>
</html>

 3.表达式+程序段 循环输出5条hr,长度分别为100px-500px

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
   

  </head>
  
  <body>
     3.表达式+程序段   循环输出5条hr,长度分别为100px-500px <br>
     <%--jsp注释 --%>
  <%
  for(int i=1;i<=5;i++){ %>
  <hr width="<%=i*50%>px">
  <% }%>
  </body>
</html>

 

 

posted on 2022-03-13 16:49  咬^O^咬  阅读(20)  评论(0编辑  收藏  举报