JSP日历
<%@ page language="java" import="java.util.*" %>
<%! string days[]; %>
<body>
<%
days=new string[42];
for(int i=0;i<42;i++)
{
days[i]="";
}
%>
<%
gregoriancalendar currentday = new gregoriancalendar();
int today=currentday.get(calendar.day_of_month);
int month=currentday.get(calendar.month);
int year= currentday.get(calendar.year);
out.println(year+"年"+ (month+1)+"月"+today+"日");
calendar thismonth=calendar.getinstance();
thismonth.set(calendar.month, month );
thismonth.set(calendar.year, year );
thismonth.setfirstdayofweek(calendar.sunday);
thismonth.set(calendar.day_of_month,1);
int firstindex=thismonth.get(calendar.day_of_week)-1;
int maxindex=thismonth.getactualmaximum(calendar.day_of_month);
for(int i=0;i<maxindex;i++)
{
days[firstindex+i]=string.valueof(i+1);
}
%>
<table border="0" width="168" height="81">
<p align=center>
<tr>
<th width="25" height="16" ><font color="red">日</font>
</th>
<th width="25" height="16" >一</th>
<th width="25" height="16" >二</th>
<th width="25" height="16" >三</th>
<th width="25" height="16" >四</th>
<th width="25" height="16" >五</th>
<th width="25" height="16" ><font color="red">六</font></th>
</tr>
<% for(int j=0;j<6;j++) { %>
<tr>
<% for(int i=j*7;i<(j+1)*7;i++) { %>
<td width="15%" height="16" valign="middle" align="center">
<%if((i-firstindex+1)==today){
%>
<font color="red"><%=days[i]%></font>
<%
} else {
%>
<%=days[i]%>
<%
}
%>
</td>
<% } %>
</tr>
<% } %>
</p>
</table>