A calendar _jsp programming with JSP
Last Update:2017-01-18
Source: Internet
Author: User
<!--File name:calendar.jsp-->
<!--display a calendar of any year or month, you can choose a different year and month. Author:wildfield-->
<%@ page language= "java" import= "java.util.*"%>
<%! String year;
String month;
%>
<% Month=request.getparameter ("month");
Year =request.getparameter ("year");
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Day </title>
<script language= "JavaScript" >
<!--
function Changemonth ()
{
var mm= "calendar.jsp?month=" +document.sm.elements[0].selectedindex+ "&year="
+<%=year%>;
window.open (mm, "_self");
}
--></script>
<%! String days[]; %>
<%
Days=new string[42];
for (int i=0;i<42;i++)
{
Days= "";
}
%>
<%
Calendar thismonth=calendar.getinstance ();
if (month!=null&& (!month.equals ("null"))
Thismonth.set (Calendar.month, Integer.parseint (MONTH));
if (year!=null&& (!year.equals ("null"))
Thismonth.set (Calendar.year, Integer.parseint (year));
Year=string.valueof (Thismonth.get (calendar.year));
Month=string.valueof (Thismonth.get (calendar.month));
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);
}
%>
<body>
<form name= "SM" method= "POST" action= "calendar.jsp" >
<%=year%> year <%=integer.parseint (month) +1%> month
<table border= "0" width= "yi" height= "Bayi" >
<div align=center>
<tr>
<th width= "height=" bgcolor= "#FFFF00" ><font color= "Red" > Day </font>
</th>
<th width= "height=" bgcolor= "#FFFF00" > </th>
<th width= "height=" bgcolor= "#FFFF00" > Two </th>
<th width= "height=" bgcolor= "#FFFF00" > Three </th>
<th width= "height=" bgcolor= "#FFFF00" > Four </th>
<th width= "height=" bgcolor= "#FFFF00" > Five </th>
<th width= "height=" bgcolor= "#FFFF00" ><font color= "green" > Six </fon
T></th>
</tr>
<% for (int j=0;j<6;j++) {%>
<tr>
<% for (int i=j*7;i< (j+1) *7;i++) {%>
<TD width= "15%" height= "bgcolor=" #C0C0C0 "valign=" Middle "align=" ce
Nter ">
<a href= "jump.jsp?year=<%=year%>&month=<%=integer.parseint (month) +1%>&d
Ate=<%=days[i]%> "target=" main "><%=days[i]%></a></td>
<%}%>
</tr>
<%}%>
</div>
</table>
<table border= "0" width= "height=" >
<tr>
<TD width=30%><select name= "Month" size= "1" onchange= "Changemonth ()" >
<option value= "0" > January </option>
<option value= "1" > February </option>
<option value= "2" > March </option>
<option value= "3" > April </option>
<option value= "4" > May </option>
<option value= "5" > June </option>
<option value= "6" > July </option>
<option value= "7" > August </option>
<option value= "8" > September </option>
<option value= "9" > October </option>
<option value= "Ten" > November </option>
<option value= "One" > December </option>
</select></td>
<TD width=28%><input type=text name= "year" value=<%=year%> size=4 maxlength
=4></td>
<td> year </td>
<TD width=28%><input type=submit value= "Submit" ></td>
</tr>
</table>
</FORM>
<script language= "JavaScript" >
<!--
document.sm.month.options.selectedindex=<%=month%>;
-->
</script>
</body>