• 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

web apps design question

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all:
I am building a web app now and everything works fine. However, instead of asking my DAO(Data access object) to connect to the DB(mysql) to retreive data for my servlet and jsp and stuff, I want to create a virtual database which holds the data.
I know that the database will be reset everytime a new user log-in but thats fine. All I need is that the database will reflect the changes within the session.
My question is that how should I designed my DB class so that it satisfy what I needed.
The current problem i have is that each time my DAO have to create an instance of my DB class (which reset all the changes that user made).
To make my question simpler for those who don't want to READ:
How can I create a class which other objects within the same package can just reference to it and the class itself have 1 instance only??
thx
 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this object specific to each user, or just the application?
If it's specific to each user, then just check for its existence in the session, if not, then create it and stick it in.
If it's specific to the application, then you can do the same thing, except put it in the servletContext.
Oh, and you'll definately want to make sure it's thread safe.
[ October 30, 2003: Message edited by: Phil Chuang ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic