Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request VS Application Context

 
Songezo Nkukwana
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the dangers of putting data (Collection) on the application Scope
? Thing is i need to share my collection between JSPs/Actions ...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to ask this in the servlets form as it's not really a Struts question.

If the data is application-wide and not user-specific--that's what the application context is *for*. The only real danger is using up memory, IMO. And possibly the need to make sure the app-scoped data is in sync with the backing DB values, but there are many ways around that.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when there is a cluster of 250 web servers hosting a "web application?" Which one of the servers will have the "shared data" Collection object? Will all of the servers have a copy of the data (object)?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I imagine it depends on how it's set up, but I'd be surprised if each machine didn't have its own application context, otherwise there would have to be a mechanism for getting the app scope from a given machine/set of machine, which defeats (one, anyway) the purpose of clustering.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic