amits
12-15-2011, 02:26 PM
Hi...
m trying to build a web application wherein users can check their college timetable...
Here's the code m using for Calender view for the user...
<%!
public int nullIntconv(String inv)
{
int conv=0;
try{
conv=Integer.parseInt(inv);
}
catch(Exception e)
{}
return conv;
}
%>
<%
int iYear=nullIntconv(request.getParameter("iYear"));
int iMonth=nullIntconv(request.getParameter("iMonth"));
Calendar ca = new GregorianCalendar();
int iTDay=ca.get(Calendar.DATE);
int iTYear=ca.get(Calendar.YEAR);
int iTMonth=ca.get(Calendar.MONTH);
if(iYear==0)
{
iYear=iTYear;
iMonth=iTMonth;
}
GregorianCalendar cal = new GregorianCalendar (iYear, iMonth, 1);
int days=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
int weekStartDay=cal.get(Calendar.DAY_OF_WEEK);
cal = new GregorianCalendar (iYear, iMonth, days);
int iTotalweeks=cal.get(Calendar.WEEK_OF_MONTH);
%>
<form name="cal" method="post" id="cal">
<table width="40%" border="0" cellspacing="0" cellpadding="0" class="ieh-fl">
<tr>
<td width="25%"> </td>
<td width="45%"> </td>
<td width="30%"> </td>
</tr>
<tr>
<td> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%"></td>
<td width="7%">
<select name="iYear" onChange="goTo()">
<%
// start year and end year in combo box to change year in calendar
for(int iy=iTYear-70;iy<=iTYear+70;iy++)
{
if(iy==iYear)
{
%>
<option value="<%=iy%>" selected="selected"><%=iy%></option>
<%
}
else
{
%>
<option value="<%=iy%>"><%=iy%></option>
<%
}
}
%>
</select></td>
<td width="73%" align="center" style="color:#4E96DE"><h3><%=new SimpleDateFormat("MMMM").format(new Date(2008,iMonth,01))%> <%=iYear%></h3></td>
<td width="6%"></td>
<td width="8%">
<select name="iMonth" onChange="goTo()">
<%
// print month in combo box to change month in calendar
for(int im=0;im<=11;im++)
{
if(im==iMonth)
{
%>
<option value="<%=im%>" selected="selected"><%=new SimpleDateFormat("MMMM").format(new Date(2008,im,01))%></option>
<%
}
else
{
%>
<option value="<%=im%>"><%=new SimpleDateFormat("MMMM").format(new Date(2008,im,01))%></option>
<%
}
}
%>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<%
int cnt =1;
for(int i=1;i<=iTotalweeks;i++)
{
%>
<tr>
<%
for(int j=1;j<=7;j++)
{
if(cnt<weekStartDay || (cnt-weekStartDay+1)>days)
{
%>
<td align="center" height="35" class="dsb"> </td>
<%
}
else
{
%>
<td align="center" height="35">
<input style="margin-center: 10px;" id="date" type="button" value="<%=(cnt-weekStartDay+1)%>" name="date" />
</td>
<%
}
cnt++;
}
%>
</tr>
<%
}
%>
</tbody>
</table></td>
</tr>
</table></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
Then user will click any date he wants the jsp would show him Schedule for that particular day....
m trying to pass date, month and year parameters to some other form on the same jsp page...but it doesn't working(getting HTTP 404 Error)...
m trying to build a web application wherein users can check their college timetable...
Here's the code m using for Calender view for the user...
<%!
public int nullIntconv(String inv)
{
int conv=0;
try{
conv=Integer.parseInt(inv);
}
catch(Exception e)
{}
return conv;
}
%>
<%
int iYear=nullIntconv(request.getParameter("iYear"));
int iMonth=nullIntconv(request.getParameter("iMonth"));
Calendar ca = new GregorianCalendar();
int iTDay=ca.get(Calendar.DATE);
int iTYear=ca.get(Calendar.YEAR);
int iTMonth=ca.get(Calendar.MONTH);
if(iYear==0)
{
iYear=iTYear;
iMonth=iTMonth;
}
GregorianCalendar cal = new GregorianCalendar (iYear, iMonth, 1);
int days=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
int weekStartDay=cal.get(Calendar.DAY_OF_WEEK);
cal = new GregorianCalendar (iYear, iMonth, days);
int iTotalweeks=cal.get(Calendar.WEEK_OF_MONTH);
%>
<form name="cal" method="post" id="cal">
<table width="40%" border="0" cellspacing="0" cellpadding="0" class="ieh-fl">
<tr>
<td width="25%"> </td>
<td width="45%"> </td>
<td width="30%"> </td>
</tr>
<tr>
<td> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%"></td>
<td width="7%">
<select name="iYear" onChange="goTo()">
<%
// start year and end year in combo box to change year in calendar
for(int iy=iTYear-70;iy<=iTYear+70;iy++)
{
if(iy==iYear)
{
%>
<option value="<%=iy%>" selected="selected"><%=iy%></option>
<%
}
else
{
%>
<option value="<%=iy%>"><%=iy%></option>
<%
}
}
%>
</select></td>
<td width="73%" align="center" style="color:#4E96DE"><h3><%=new SimpleDateFormat("MMMM").format(new Date(2008,iMonth,01))%> <%=iYear%></h3></td>
<td width="6%"></td>
<td width="8%">
<select name="iMonth" onChange="goTo()">
<%
// print month in combo box to change month in calendar
for(int im=0;im<=11;im++)
{
if(im==iMonth)
{
%>
<option value="<%=im%>" selected="selected"><%=new SimpleDateFormat("MMMM").format(new Date(2008,im,01))%></option>
<%
}
else
{
%>
<option value="<%=im%>"><%=new SimpleDateFormat("MMMM").format(new Date(2008,im,01))%></option>
<%
}
}
%>
</select></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<%
int cnt =1;
for(int i=1;i<=iTotalweeks;i++)
{
%>
<tr>
<%
for(int j=1;j<=7;j++)
{
if(cnt<weekStartDay || (cnt-weekStartDay+1)>days)
{
%>
<td align="center" height="35" class="dsb"> </td>
<%
}
else
{
%>
<td align="center" height="35">
<input style="margin-center: 10px;" id="date" type="button" value="<%=(cnt-weekStartDay+1)%>" name="date" />
</td>
<%
}
cnt++;
}
%>
</tr>
<%
}
%>
</tbody>
</table></td>
</tr>
</table></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
Then user will click any date he wants the jsp would show him Schedule for that particular day....
m trying to pass date, month and year parameters to some other form on the same jsp page...but it doesn't working(getting HTTP 404 Error)...