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

  • Home
  • SEARCH
  • 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 5944919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:36:31+00:00 2026-05-22T16:36:31+00:00

I store Birthday Month in database as value using following code in JSP. <select

  • 0

I store Birthday Month in database as value using following code in JSP.

<select name="birthday_month" id="birthday_month">
  <option value="-1">Month</option>
  <option value="1">Jan</option>
  <option value="2">Feb</option>
  ...
</select>

Output code in JSP to show previously selected item using JSTL that I am using (which is not correct)

<select name="birthday_month" id="birthday_month">
  <c:forEach var="value" items="${birthdaymonth}">
    <option value="${birthdaymonth}">${birthdaymonth}</option>
    <option value="1">Jan</option>
    <option value="2">Feb</option>
    ...
  </c:forEach>
</select>

What I am getting from this code is value like 1 or 2 in select tag

Other Information:

  1. I store birthday month as value like 1,2,3.. for Jan,Feb,Mar… in Database
  2. I bring value of birthday month in request scope in Servlet using
    request.setAttribute("birthdaymonth", user.getBirthdayMonth());

What i was expecting

  1. When i show later JSP it should show previously stored birthday month as Jan,Feb, Mar and not 1,2,3 and also show other Option values including selected item as highlighted.
  • 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-22T16:36:31+00:00Added an answer on May 22, 2026 at 4:36 pm

    To dynamically iterate over a collection of months, you’d like to store the months in a Map<Integer, String> where the key is the month number and the value is the month name. To make a HTML <option> element by default selected, you need to set the selected attribute.

    So, assuming that you have a Map<Integer, String> months and a Integer selectedMonth in the scope, then the following should do:

    <select name="birthday_month">
        <c:forEach items="${months}" var="month">
            <option value="${month.key}" ${month.key == selectedMonth ? 'selected' : ''}>${month.value}</option>
        </c:forEach>
    </select>
    

    The conditional operator ?: will print selected when the selectedMonth is equal to the currently iterated month number.

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

Sidebar

Related Questions

I have this code to load the month of the birthday that corresponds to
I store various user details in my MySQL database. Originally it was set up
I store file’s attributes (size, update time…) in database. So the problem is how
To store application settings, I am using the Settings tab in the project properties.
Store No Store Name Region Division Q10(response) Q21(response) 2345       ABC              North
We store documents in an SQL Server 2005 database table with a column format
I store the long values in mssql using bigint so I could do something
To store only time from DateTime into SQL Server 2005. I am using vs.net
echo $form->input('birthday', array( 'label' => 'Birthday', 'type' => 'date', 'dateFormat' => 'MDYMDY', 'value' =>
When executing the following using a smalldatetime constraint on the returned results, I get

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.