• 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

Variable Integrity---I'm scared!!!

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding as servlets are concerned is that there is only one instantiation of a servlet at any given time, and that instantiation handles all the requests. This makes me very scared as the variables could be changed halfway thru execution by another incoming request. It is impossible for me to simulate the environment the servlet will be running in while I am testing, I cant send it many requests at once to check that the data integrity is intact. This seems like a fundamental question as servlets are concerned, but it is not mentioned in the books I have on servlet programming, am I totally lost or worrying needlessly about this? Any bones thrown my way are greatly appreciated.
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this is a major concern, you can always resort to synchronization, or the single thread model.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It all depends on the details but most of your concerns can be addressed with sessions.
 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as the synchronization or single thread model, would that not SERIOUSLY degrage performance due to overhead, and be a programming nightmare.
And as for the session, would you put the request/response in the session, and would that be the first line in the servlet, and also is it not possible that when the code is executing one request and putting it in a session, another request could come in and change the response before it was put in the session.
Or do you need to combine both approaches to optimize integrity, synchronize the code that puts the request/respose pair in the session which could be realistic, then just get them from the session when needed. But is that a fundamentally sound way to approach this problem, and would that stand up to 100-1000 concurrent connections.I'm still seaching for simplicity and elegance, but maybe its just not there.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the Single-Model Interface will hurt your performance. I believe all waiting requests get queued. Synchronization would probably be a better idea, making sure you only synchronize what is indeed important. I know I've read about this. I couldn't find it in O'Reilly's servlet book, but I did come across this in the Core Java Servlets and Java Server Pages:
page 154 near the bottom:
"Of, course the normal rules that require authors to synchronize multithreaded access to shared data still apply to servlets."
If I come across something else, I let you know.
- Sean
 
reply
    Bookmark Topic Watch Topic
  • New Topic