JSP第二次作业
<%@ 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> </head> <body> <% //java注释 Date d=new Date(); int h=d.getHours(); //获取小时 int m=d.getMinutes();//获取分钟 int s=d.getSeconds();//获取秒 out.print("当前时间:"+h+":"+m+":"+s+"<br>"); if(h>=0&&h<=12){ out.print("早上好"); }else if(h>=13&&h<=17){ out.print("下午好"); }else if(h>=18&&h<=23){ out.print("晚上好"); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%! boolean sf(int year){ if(year%4==0&&year%100!=0||year%400==0){ return true; } return false; } %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <!-- HTML注释 --> <title>My JSP 'index1.jsp' starting page</title> </head> <body> <% boolean f=sf(2023); out.print(f); %> </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 'index1.jsp' starting page</title> </head> <body> <%--jsp注释 --%> <% for (int i = 1; i <= 5; i++) { %> <hr width="<%=i * 100%>px"> <% } %> </body> </html>