aspose file tools*
The moose likes Servlets and the fly likes how servlet process the different client request??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how servlet process the different client request???" Watch "how servlet process the different client request???" New topic
Author

how servlet process the different client request???

gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
Hi All,

If multiple client access the same servelt, then it creates thread.
it means that only when the first thread completes then only it call the second thread.

is it correct???

if it is correct , then the process will be slow......

i am confused with this.........

please clear my doubt..

how servelt process the request???


thanks in advance
Gopal
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

it means that only when the first thread completes then only it call the second thread.

is it correct???


No, not correct. The whole point of threads is that they execute simultaneously.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
hi,

But by default, the servlet is THREAD SAFE
<%@ page isthreadsafe="true">

please clarify

Gopal
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

That is a JSP directive and has nothing whatsoever to do with servlets that are not JSPs.

And within JSPs, that directive does not make a JSP thread-safe. It is a directive that tells the container that you have written the JSP in a thread-safe manner.
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
Thanks bear,

please check my understanding is correct...

if threadsafe = true , means the container creates a thread for the request and maintain a single instance of servlet,

whereas if threadsafe= false, the container creates multiple instances of servlet class instead of creating a thread.

am i right??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

No, not right.

And again, this has nothing to do with general servlets. Only JSPs.

If you set threadsafe=false, the container will serialize access to the JSP. Not a good idea as it would likely result in performance degradation.
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
thanks bear, i got it..

but last doubt..

when the container creates multiple servelt instance???
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
HI Gopal
Container never maintains multiple servet instances. I creates only one instance of the servlet, when the first request is executed or u have selected load on start up option. Thereafter only each thread gets executed per request.
There was a interface before called as SingleThreadModel which is deprecated now. Some documentation says that when u implement this model, you are guaranteed that no two threads will execute concurrently in the servlet's service method or container may create multiple instances of the servlet where each request is assigned one. There was a whole lot of confusion with this interface as it was a marker interface.
Today u must remember one point, there is one and only one instance created for servlet instance.

Let me know if i am wrong or making any sense 2 u.

Regards
Makarand Parab
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
Hi All,

Thanks for your reply.

Now i am clear with your replies.


thanks
Gopal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how servlet process the different client request???