A calendar program _jsp programming implemented with JSP

Source: Internet
Author: User

<!--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[i]= "";
}
%>
<%
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++) {%>
&LT;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>
&LT;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>
&LT;TD width=28%><input type=text name= "year" value=<%=year%> size=4 maxlength
=4></td>
<td> year </td>
&LT;TD width=28%><input type=submit value= "Submit" ></td>
</tr>
</table>
</FORM>
<script language= "JavaScript" >
<!--
document.sm.month.options.selectedindex=<%=month%>;
-->
</script>
</body>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.