Please refer the Servlet API for more information.
Originally posted by Ceenu Reddy:
If there are more than one request for the same servlet then the container will responsible to create the pool of servlet instances and dispatch each new request to the free one.
There will be a single instance of each servlet class. If am not Wrong.
Container will responsible means.... I need not to make any code change to handle multiple requests. ( other than session management) ?
Originally posted by Raghavendra Nittur:
Can you suggest me how i can write my servlets in a thread safe manner.
What do i need to refer. Am new to Servlets.
Since now you have understood that multiple threads (one for each client's request) will execute service() method at the same time, you need to make sure that your data is in consistent state.
There are different scope objects exist in JSP/Servlet (I hope the word is right): request, session, config, context and page (page is only in JSP).
Request data are by default thread safe since one thread per request.
Session data, you don�t need to make thread safe because you will intentionally want to update it.
Config and Context, you need to take care of...
I am 100% sure I am not 100% correct above. Please someone correct me.