Я бы создал календарь в контроллере, например, так:
@Controller
public class CalendarController{
private static final int START_OF_WEEK = DateTimeConstants.MONDAY;
@RequestMapping("drawCalendar")
public ModelAndView drawCalendar(@RequestParam("month") final int month,
@RequestParam("year") final int year){
final LocalDate monthStart = new LocalDate(year, month, 1);
boolean endReached = false;
LocalDate today = null;
final List<List<LocalDate>> weeks1 = new ArrayList<List<LocalDate>>();
while(!endReached){
final List<LocalDate> thisWeek = new ArrayList<LocalDate>();
for(int weekOffset = 0; weekOffset < 7; weekOffset++){
if(today == null){
if(!endReached
&& weekOffset == monthStart.getDayOfWeek()
- START_OF_WEEK){
today = monthStart;
}
} else{
today = today.plusDays(1);
if(today.getMonthOfYear() != month){
today = null;
endReached = true;
}
}
thisWeek.add(today);
}
weeks1.add(thisWeek);
}
final List<List<LocalDate>> weeks = weeks1;
final Map<String, Object> model = new HashMap<String, Object>();
model.put("calendar", weeks);
final ModelAndView modelAndView = new ModelAndView("calendar", model);
return modelAndView;
}
}
, а в JSP я бы повторял по неделям:
<c:forEach items="${calendar}" var="week">
<tr>
<td>Mon</td>
<td>Tue</td>
<td>Wed</td>
<td>Thu</td>
<td>Fri</td>
<td>Sat</td>
<td>Sun</td>
</tr>
<tr>
<c:forEach items="${week}" var="date">
<td><c:out value="${date==null ? '' : date.dayOfWeek}"</td>
</c:forEach>
</tr>
</c:forEach>
(конечно, яне писал код JSP в течение 3 лет, извините, если что-то не так)