Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-15-2011, 02:26 PM   PM User | #1
amits
New to the CF scene

 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
amits is an unknown quantity at this point
JSP Calender Application

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%">&nbsp;</td>
<td width="45%">&nbsp;</td>
<td width="30%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</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">&nbsp;</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>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</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)...
amits is offline   Reply With Quote
Reply

Bookmarks

Tags
multiple forms, pass parameters

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:37 PM.


Advertisement
Log in to turn off these ads.