A calendar program implemented by JSP

Source: Internet
Author: User


<! -- Display the calendar of any year or month. You can select a different year or month. Author: wildfield -->
<% @ Page language = "java" import = "java. util. *" %>
<%! String year;
String month;
%>
<% Month = request. getParameter ("month ");
Year = request. getParameter ("year ");
%>
<Html>
<Head>
<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>
</Head>
<%! 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 = "168" height = "81">
<Div align = center>
<Tr>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> <font color = "red"> day </font>
</Th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> 1 </th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> 2 </th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> 3 </th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> 4 </th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> 5 </th>
<Th width = "25" height = "16" bgcolor = "# FFFF00"> <font color = "green"> 6 </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 = "16" 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 = "168" height = "20">
<Tr>
<Td width = 30%> <select name = "month" size = "1" onchange = "changeMonth ()">
<Option value = "0"> August 1, January </option>
<Option value = "1"> April February </option>
<Option value = "2"> August 1, March </option>
<Option value = "3"> August 1, April </option>
<Option value = "4"> August 1, May </option>
<Option value = "5"> August 1, June </option>
<Option value = "6"> August 1, July </option>
<Option value = "7"> August 1, August </option>
<Option value = "8"> August 1, September </option>
<Option value = "9"> October </option>
<Option value = "10"> November </option>
<Option value = "11"> August 1, 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>
</Html>

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.