• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose differentusers are connected to the same web page
how a servlet distinguishes all the req's
asked in one interview
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kandukuri ramesh:
Suppose differentusers are connected to the same web page
how a servlet distinguishes all the req's
asked in one interview

The Web Server/App Server gives each request it's own instance of your Servlet object, The are as independant as 2 objects made for the same class in one program.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The normal situation is that there is one single instance of the servlet object - that is why you must not use instance variables, because multiple users will get them mixed up. You can force the servlet container to use a separate instance per user by implementing the SingleThreadModel interface, but this is frowned on as it can be much slower and use more memory.
Each request gets a separate Thread, so you only use variables that are created inside the doGet or doPost method - these are specific to the Thread. If you want to save user data between request-response cycles, you use a HttpSession object that the servlet container keeps track of for you.
 
ramesh kandukuri
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply(william & carl)
Is there any online links(free) for learnig more on sessions and
cookies?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets are being discussed all over the web these days, just do a search at Yahoo. A good site is www.servlets.com, but there are plenty more.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic