• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading Data at app startup

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a situation where on each login huge data is fetched from database and stored into the users session. I do not want the database query to run every time and want to load the data at application startup in applicaion scope thus making session contain less data and also decreasing the database query time. My whole application is getting the data currently from session and I donot want to change it. Is there a way to do this ?
Is it possible to override weblogic 10.3's HttpSession implementation and override getAttribute() to do my work.

Thanks,
Subhadeep
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand you correctly you need just one copy of that data, and it should be fetched only once. You could put the data in a static variable, check if it's empty and fill it form DB.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a web application, people typically do this in servlet and load that servlet on startup using web.xml like


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A startup listener should be preferred to an init servlet
 
Sunil Kumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than servlet use listener. Read the comment from Ben Souther
https://coderanch.com/t/361567/Servlets/java/load-startup-tag-Vs-listener
 
Sunil Kumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, right David. https://coderanch.com/t/361567/Servlets/java/load-startup-tag-Vs-listener will help differentiate amongst the two as i said above.
Thanks David.
 
Marshal
Posts: 79505
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to servlets forum.
 
subhadeep chakraborty
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Thanks for you response.My existing application gets the data from session and if I store the data in application
context I shall have to go through the whole application and change.I do not want to do that.

Is it possible to override weblogic 10.3's HttpSession implementation and override getAttribute() to do my work.

Is there a different way?

Thanks,
SUbhadeep
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applying a band-aid that will make your code fragile and confusing is not the best approach. Take the time to refactor the code properly.
 
grapes are vegan food pellets. Eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic