public void printCalendar(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException { printTop(request, response); PrintWriter out = response.getWriter(); CRSManager c = new CRSManager(); String id = request.getParameter("id"); if (!id.equals("") & !id.equals("0") & c.isLab(dbcon, id)) { GregorianCalendar gcMin = new GregorianCalendar(); GregorianCalendar gcMax = new GregorianCalendar(); GregorianCalendar current = new GregorianCalendar(); Date min = c.getMinDate(dbcon, id); Date max = c.getMaxDate(dbcon, id); Date curr = new Date(); List pers = c.getPeriods(dbcon, id); current.setTime(curr); gcMin.setTime(min); gcMax.setTime(max); gcMax.add(Calendar.DAY_OF_MONTH,-1); SimpleDateFormat sf = new SimpleDateFormat("EEEE, MMM d"); if(gcMin.get(Calendar.DATE) < current.get(Calendar.DATE)){ gcMin.setTime(curr); } else if(gcMin.get(Calendar.DATE)> current.get(Calendar.DATE)) { gcMin.setTime(min); } else { gcMin.setTime(curr); } out.println(sf.format(gcMax.getTime())); out.println("
"); while (!gcMin.equals(gcMax)) { if(gcMin.get(Calendar.DAY_OF_WEEK)!=Calendar.SATURDAY & gcMin.get(Calendar.DAY_OF_WEEK)!=Calendar.SUNDAY){ out.println(""); out.println(""); for (int i = 0; i < pers.size(); i++) { Period p = (Period) pers.get(i); String per = String.valueOf(p.getId()); ReservationCal r = c.getReservation(dbcon, per, gcMin.getTime()); if (r.getUsername().equals("Nobody") & r.getRoom() == 0) { out.println(""); } else { out.println(""); } } gcMin.add(Calendar.DAY_OF_MONTH, 1); } out.println("

" + sf.format(gcMin.getTime()) + "
" + p.getName() + "

" + "Reserve
" + p.getName() + "
" + r.getUsername() + "
" + r.getRoom() + "
Unreserve
"); } } else { out.println("

You have not entered a correct lab id, please go back and try the link again

" + "

If you have gotten this error more than once when clicking a link, please report " + "this error to Technology

"); } printBottom(request, response); }