<%@page import="java.text.SimpleDateFormat"%>
<%@ 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>
我爱你中国
<%String name="赵辰阳"; %>
<br/>
你的姓名是:<%=name %>
<br/>
<%
int num=1;
int num1=1;
%>
俩数的总和是: <%=num+num1 %>
<br/>
<br/>
<!-- 方法声明 -->
<%!
String formatDate(Date d){
java.text.SimpleDateFormat format=new SimpleDateFormat("yyy年MM月dd日");
return format.format(d);
}
%>
第一次调用今天是:<%=formatDate(new Date()) %>
<br/>
第二次调用今天是:<%=formatDate(new Date()) %>
</body>
</html>
闰年
<%@ 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 '2.jsp' starting page</title>
</head>
<body>
<%
int count=0;
for(int i=2000;i<2014;i++){
if((i%4==0&&i%100!=0)||(i%400==0)){
count++;
}
}
%>
有<%=count %>个闰年
</body>
</html>
jsp 方法声明 计算闰年
最新推荐文章于 2023-10-23 11:36:13 发布