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>
    <%
    Calendar c=Calendar.getInstance();
    int hour=c.get(Calendar.HOUR);
    out.print("现在的时间是 "+hour+"");     //输出时间点
    if(hour<=12){    
     %>
     上午好
     <%}else if(hour>=13&&hour<=18){ %>
     下午好
     <%} else if(hour>18&&hour<=23){ %>
     晚上好
     <%}
      %>
       </body>
</html>

 

 

<!-- HTML注释 -->
<%!int year = 2023;%>
<%
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
out.print("2023是闰年");
} else {
out.print("2023不是闰年");
}
%>

 

 

<%@ 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" >
<% } %>
  </body>
</html>

 

posted @ 2022-03-29 06:56  藜莂  阅读(21)  评论(0编辑  收藏  举报