第二次作业....
<%@ 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>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<%
for(int i=1;i<6;i++){%>
<hr width="<%=i*100%>" >
<%} %>
</body>
</html>

1.p39 实验2 显示当前时间,并输出上午(0-12)好,下午好(13-17),晚上好(18-23)
<%@ 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>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<%
Calendar c=Calendar.getInstance();
int a=c.get(Calendar.HOUR);
int m=c.get(Calendar.MINUTE);
if(0<=a&&a<=12)
out.print("早上好");
if(13<=a&&a<=17)
out.print("早上好");
if(18<=a&&a<=23)
out.print("早上好");
out.print("现在是"+a+":"+m);
%>
</body>
</html>

2. 使用声明方法,在页面调用该方法,判断2023是不是闰年
闰年:能被4整除但不能被100整除或者能被400整除
<%@ 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>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<%!int a=2023;%>
<% if(a/4==0&&a/100!=0||a/4==0)
out.print("2023是闰年");
else
out.print("2023是不闰年");
%>
</body>
</html>

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

浙公网安备 33010602011771号