This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how servlet process the different client request???

 
gopal kishan
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64190
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
gopal kishan
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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

please clarify

Gopal
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64190
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64190
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bear, i got it..

but last doubt..

when the container creates multiple servelt instance???
 
Makarand Parab
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks for your reply.

Now i am clear with your replies.


thanks
Gopal
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic