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

The Archive Base Latest Questions

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

how can i load data into memory with a tomcat server ? i have

  • 0

how can i load data into memory with a tomcat server ?

i have a java class that load data from a file.
i want to load the data into memory once and that every time the client request a page that uses that class the data will be used from the memory.

for example

class MyClass
{
      HashMap data = new HashMap(100);
      public void LoadDataFromFile()
      {.....}
      public void UseTheData(String input)
      {....}
      public MyClass(){ LoadDataFromFile();}  // c'tor load data
      public SetInput(String Input)
      {
           UseTheData(input);
      }
}

and in my jsp file

Myclass myclass= new MyCass();
myclass.LoadDataFromFile();
myclass.UseTheData();

i know i should use JSTL in the jsp file

if i use the scope=”session” will the data loading will remain ?

<jsp:useBean id="myclass" class="MyClass" scope="session">
<jsp:setProperty name="myclass" property="input" value="blabla" />
</jsp:useBean>

if i do the data loading in the constructor, can i make sure the class is init only once ?

  • 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-23T15:21:35+00:00Added an answer on May 23, 2026 at 3:21 pm

    Create a ServletContextListener and register it in your web.xml file. In the ServletContextListener, when the application is initialized, read the file and store it in an attribute of the ServletContext. This attribute is then easily accessible from your Java and JSP code.

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

Sidebar

Related Questions

I have a CSV of file of data that I can load in R
When I first load data into a Silverlight DataGrid control, how can I make
When using PyWin I can easily load a python file into a fresh interactive
If I'm running a signed Java applet. Can I load additional classes from remote
I am trying to load data from XML string into a structure of some
I have written some code that pulls info from a plist file and does
I have an unnormalized events-diary CSV from a client that I'm trying to load
If all tables I want to delete from have the column gamer_id can i
I have a System.XML.Schema.XmlSchema loaded into memory and an XML instance data of element
I have a little problem with a Listview. I can load it with listview

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.