A calendar program implemented with JSP __jsp

Source: Internet
Author: User

Use JSP Calendar programs that are implemented

Tieshu

Tieshu

Rngguliu@163.com

April 4, 2006 Tuesday

Can display any year, the current day plus a background color, the weekend is red. This calendar program is part of my Schedule management program (with a Schedule management effect chart). 1 Effect Chart

effect chart for schedule management

2 JSP Code

<body>

<jsp:usebean id= "Bean" class= "general. Canlendarface "/>

<%

String year, month, date;

Year = Request.getparameter ("year");

month = Request.getparameter ("month");

Date = Request.getparameter ("date");

Out.println (bean.showhtml (year,month,date));

%>

</body>

3 JavaBean Code

/**

* @author Cycas

*/

Package General.calendar;

Import java.util.*;

public class Canlendarface {

public string showHTML (string year, string month, string date) {

int y, M, D;

GregorianCalendar temp= New GregorianCalendar ()//Get current calendar (Grigory)

try {

y = integer.parseint (year);

m = integer.parseint (month);

D = integer.parseint (date);

catch (Exception e) {

y = Temp.get (gregoriancalendar.year); Year of acquisition;

m = Temp.get (Gregoriancalendar.month); The Month taken

D = Temp.get (Gregoriancalendar.day_of_month); The current day taken

}

if (y<1900 | | y>9999) Y=temp.get (gregoriancalendar.year); Year of acquisition;

if (m==-1) {

y--;

m=11;

}else if (m==12) {

y++;

m=0;

}else if (m<-1 | | m>12) {

m = Temp.get (Gregoriancalendar.month); The Month taken

}

if (d<1 | | d>31) d=1;//Default Day

Calendar thismonth = Calendar.getinstance ();

Thismonth.set (Y, M, d);

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);

String[] days = new STRING[42];

for (int i = 0; i < i++) {//initialization of tabular data

Days[i] = "&nbsp;";

}

for (int i = 0; i < Maxindex i++) {//Initialize with actual date worth part

Days[firstindex + i] = string.valueof (i + 1);

}

String face = "";

Face + + "<table id=/" t1/"width=/" 91%/"border=/" 1/"align=/" center/"cellpadding=/" 2/"cellspacing=/" 1/" bordercolordark=/"#94CCF6/" bordercolorlight=/"#fefefe/" > ";

Face + = "<tr>";

Face + + "<td height=/" 35/"colspan=/" 7/"align=/" center/"bgcolor=/" #CAE8FF/">";

Face + + "<a href=/" daily.jsp?year= "+ (y-1) +" &month= "+m+" &date=1/"> Previous year </a>&nbsp;";

Face + + "<a href=/" daily.jsp?year= "+y+" &month= "+ (m-1) +" &date=1/"> Last month </a>";

Face + + "<strong class=/" style4/">" + y + "year" + (M + 1) + "month </strong>";/"+d +" Day

Face + + "<a href=/" daily.jsp?year= "+y+" &month= "+ (m+1) +" &date=1/"> next month </a>&nbsp;";

Face + + "<a href=/" daily.jsp?year= "+ (y+1) +" &month= "+m+" &date=1/"> next year </a>";

Face + = "</td></tr>";

Face + = "<tr>";

Face + = "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"><span class=/" style3/"> Day </span> </td> ";

Face + + "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"> </td>";

Face + + "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"> Two </td>";

Face + + "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"> Three </td>";

Face + + "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"> Four </td>";

Face + + "<td width=/" 14%/"align=/" center/"bgcolor=/" #C8E1FA/"> Five </td>";

Face + + "<td align=/" center/"bgcolor=/" #C8E1FA/"><span class=/" style3/"> Six </span></td>";

Face + = "</tr>";

for (int j = 0; J < 6; J + +) {

face = + "<tr id=/" line "+ j +"/">";

String status = "status=yes,scrollbars=yes,resizable=yes,width=640,height=480";

for (int i = j * 7; I < (j + 1) * 7; i++) {

if (i==35 && days[i].equals ("&nbsp;")) {

Face + + "<script>line5.style.display=/" none/"</script>";//"<td>&nbsp;</td>";

Break

}

if (Days[i].equalsignorecase string.valueof (Temp.get (gregoriancalendar.day_of_month)) && y = = Temp.get ( gregoriancalendar.year) && m = = Temp.get (gregoriancalendar.month)) {

Face + + "<TD bgcolor=/" #E7FEE8/"height=/" 50/"align=/" center/"<span class=/" style10/">";

}else if ((i%7) ==0 | | ((i+1)%7) ==0) {

Face + + "<td height=/" 50/"align=/" center/"<span class=/" style6/">";

}else{

Face + + "<td height=/" 50/"align=/" center/"<span class=/" style7/">";

}

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.