Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3333864
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:50:34+00:00 2026-05-17T23:50:34+00:00

I have a Java bean which stores what I am calling meta data (week

  • 0

I have a Java bean which stores what I am calling meta data (week start day, any holidays) that my JSP view will use to display a Calendar Month. I am using JSTL, not EL, since company only has jsp 1.2

  <table align="center" border="1" cellpadding="3" cellspacing="0" width="100%" class="tableInternalBorder">
     <tbody>
        <tr>
           <th width="180px" class="optionYellow">Sun</th>
           <th width="180px">Mon</th>
           <th width="180px">Tue</th>
           <th width="180px">Wed</th>
           <th width="180px">Thu</th>
           <th width="180px">Fri</th>
           <th width="180px" class="optionYellow">Sat</th>
        </tr>

        <c:forEach var="week" begin="1" end="${calendar.totalWeeks}" varStatus="status">
           <tr>
           <c:forEach var="cell" begin="${1+7*(week-1)}" end="${7+7*(week-1)}" step="1" varStatus="status"><c:set var="dayNo" value="${cell-calendar.weekStartDay+1}" />
               <c:choose><c:when test="${calendar.weekStartDay>cell || (cell-calendar.weekStartDay+1)>calendar.totalDays}">
               <td height="50" class="<c:out value="${calendar.cellColor[cell]}" />">*&nbsp;</td>
               </c:when>
               <c:otherwise>
               <td valign="Top" height="75px" class="<c:out value="${calendar.cellColor[dayNo]}" />"><span class="calDayNo"><c:out value="${dayNo}" /></span><span class="calDayName"> <c:out value="${calendar.holidayName[dayNo]}" /></span><br>
               <c:forEach var="dayEvent" items="${eventMap.byDay[dayNo]}" varStatus="status"><div class="eventContent" ><c:out value="${status.count}" />) <c:out value="${dayEvent.event_type_name}" />: <c:out value="${dayEvent.eventUser.lastName}" /></div></c:forEach></td>
               </c:otherwise>
               </c:choose>
           </c:forEach>
           </tr>
        </c:forEach>
     </tbody>
  </table>

In this bean I also storing an array of month names so that I can do this in my view.

<c:forEach var="month" items="${calendar.monthList}" varStatus="status">
    <option value="<c:out value="${status.index}" />" <c:if test="${month == calendar.monthName}">selected</c:if>><c:out value="${month}" /></option>
</c:forEach>

My question is do I set the month list in my javabean or the method which generates the meta data for the calendar. Here is the method that returns to meta data bean (with logic removed for clarity). Should I set it in this method, this class, or in the Java bean. If it should go in the Java bean, I am not sure how to do that.

public EBCalendar getCalendarMeta (HttpServletRequest request) {
    //Get any request parameters
    int iYear = STKStringUtils.nullIntconv(request.getParameter("iYear"));
    int iMonth = STKStringUtils.nullIntconv(request.getParameter("iMonth"));
    EBCalendar ebCal = new EBCalendar();

// Get the current month and year
    Calendar ca = new GregorianCalendar();
    int curYear = ca.get(Calendar.YEAR);
    int curMonth = ca.get(Calendar.MONTH);

// If request parameters are null use todays calendar
    if (iYear == 0) {
        iYear = curYear;
        iMonth = curMonth;
    }
    ebCal.setCurYear(curYear);
    ebCal.setCurMonth(curMonth);
    ebCal.setSelYear(iYear);
    ebCal.setSelMonth(iMonth);

    ebCal.setTotalWeeks(iTotalweeks);
    ebCal.setTotalDays(totalDays);
    ebCal.setWeekStartDay(weekStartDay);
    ebCal.setAbvMonthName(abvMonthName);
    ebCal.setMonthName(monthName);
    ebCal.setMonthList(monthList);
    ebCal.setHolidayName(getEBHolidayNameInMonth(iYear, iMonth));
    ebCal.setCellColor(getWeekendHolidayColorMap(iYear, iMonth));

    return ebCal;
}

EDIT: Here is what I did based on the accepted answer

I changed this:

<c:forEach var="month" items="${calendar.monthList}" varStatus="status">
    <option value="<c:out value="${status.index}" />" <c:if test="${month == calendar.monthName}">selected</c:if>><c:out value="${month}" /></option>
</c:forEach>

to this:

<c:set var="months">January,February,March,April,May,June,July,August,September,October,November,December</c:set>
<c:forTokens var="month" items="${months}" delims="," varStatus="status">
  <option value="<c:out value="${status.index}" />" <c:if test="${month == calendar.monthName}">selected</c:if>><c:out value="${month}" /></option>
</c:forTokens>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:50:34+00:00Added an answer on May 17, 2026 at 11:50 pm

    I think the question here is should you put the default with the view or the model. I am a bigger fan of putting the default with the model because you may have a different jsp that will have different defaults in the future. Then you have to go back and change the default in your model. I vote for in JSP. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Java have a data type that represents a period of time eg 34
Does Java have a built-in way to escape arbitrary text so that it can
I have done Java and JSP programming in the past, but I am new
I have a Java swing application with a panel that contains three JComboBoxe s
I have a java back-end that needs to expose services to clients running in
I have a Java application that launches another java application. The launcher has a
I have a Java application which I want to shutdown 'nicely' when the user
I have Java and Flash client applications. What is the best way for the
Here is what I have: JAVA_HOME=C:\Software\Java\jdk1.5.0_12 (points to JDK 5.0) In Eclipse Installed Runtimes
Does Java have buffer overflows? If yes can you give me scenarios?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.