Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting scopes  RSS feed

 
pree sree
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am new to web programming, and i am preparing for my scwcd.i am confused regarding the scope types.i.e, when u set the scope=application and scope=session what is the difference and how r these 2 scenarios used in a web application? and also when does the server create a new instance of the servlet?(does it create an object for every request?)(do please suggest some tutorials to clarify these ?s)
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI pree ,
The best book according to me for SCWCD is H&F. The application scope is for whole web application where as the session scope is for a particular session(requests from the same user participating in the session). Scenario where you can use these objects are like suppose you have to set a attribute that will be availabe to whole web application for this you can use application scope whereas if you want the attribute to be availabe only for a particular user session then you can use session object.

The servlet container will create only one instance of a servlet and will allocate a thread for each request. If your servlet implements SingleThreadModel then servlet container may create multiple instances.

Hope that helps.

Sawan
 
pree sree
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!