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 6049433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:34:36+00:00 2026-05-23T07:34:36+00:00

Good day! I am modifying some codes from an existing program. Before the program

  • 0

Good day!

I am modifying some codes from an existing program.
Before the program begins, they initialize all the dropdown list and store it in a session.

Is it okay to store the list of my dropdown menu in a session?
Note: the list is from the database.

SAMPLE CODE:

           HttpSession session = request.getSession();

        session.setAttribute("accountList", accountList);
        session.setAttribute("contractorAgencyList", contractorAgencyList);
        session.setAttribute("employeeStatusList", employeeStatusList);
        session.setAttribute("movementTypeList", movementTypeList);
        session.setAttribute("positionLevelList", positionLevelList);
        session.setAttribute("positionRoleList", positionRoleList);
        session.setAttribute("practiceCodeList", practiceCodeList);
        session.setAttribute("projectUtilizationList", projectUtilizationList);
        session.setAttribute("siteLocationList", siteLocationList);
        session.setAttribute("taxStatusList",taxStatusList);
        session.setAttribute("turnoverTypeList",turnoverTypeList);
        session.setAttribute("projectList",projectList);

Are there other ways to do this? If this is the most common way to do this, then How can we avoid the session from being lost?

Thank you.

  • 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-23T07:34:36+00:00Added an answer on May 23, 2026 at 7:34 am

    Are there other ways to do this?

    Yes, but that would depend on how long you want the values to be stored. In a Servlet container, you typically have access to Application scope, Session scope, Request scope and Page scope. The first three can be accessed in both servlets and JSPs, while the last is useful only in the context of a JSP.

    If the contents of the menu can be reused across sessions, it is better to store them in application scoped objects, via the ServletContext interface.

    If you do not need the menu data beyond the current request, then you ought to make it request-scoped, and not session-scoped.

    If the scope of the drop down menu is however, restricted to a session, then it is a better idea to store it in a session as long as the object does not consume a lot of space. Keep in mind, that the size of the objects stored in memory will affect performance of the site, especially when a clustering and session replication strategy is in place – this is primarily because the contents of the session have to be serialized and stored for the possibility of creating a different session on failover.

    Also, performance will be affected even if you are not employing a clustering and session migration strategy, as each session will consume memory that will be released only upon the next GC cycle after session invalidation.

    If you wish to avoid using sessions to store session-scoped objects, you can query the data from the database on an as needed basis. Or even store the contents in files (as long as they are not confidential/sensitive data), which can make your session migration strategy a bit more painful.

    If this is the most common way to do this, then How can we avoid the session from being lost?

    I didn’t understand this part of the question. In any case, sessions are managed by the container on behalf of the application developer. At most, a developer may specify the session timeout values that will dictate the extent of the rolling-window for session expiry. The developer may also invalidate the session at some significant point in the application’s navigation flow – for instance, on click of a logout button. The developer typically does not need to worry about managing the sessions, beyond what needs to be done using the HttpSession API, or entries in the deployment descriptors.

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

Sidebar

Related Questions

Good day dear colleagues, I decided to move some projects from MySQL to MongoDB
Good day. I have a dropdown list control called audioList. Whenever the page loads
Good day, I am having trouble modifying XML using SimpleXMLElement in PHP. My XML
Good day, I have a question here. I am trying to fetch image from
Good day! I've recently switched from IIS 6.0 to IIS 7.x and I'm in
Good day all I wrote the following method: private void RegisterEvent(object targetObject, string eventName,
Good day, I've been doing some modifications to this website and the owner wants
Good day! I encountered the following error upon running my JSP program. java.lang.IllegalStateException: PWC3991:
Good day to all. I have the following setup: A page with html, js,
Good day all, for running multiple threads concurrently is it advisable to create different

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.