• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread safety - Request Dispatching

 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I would like to ask 2 question at the same time...

The first question is that are local variables in doGet, doPost methods in Servlets are thread-safe ?
I know that instance variables are not thread-safe in Servlets.

The second question is about request dispathcer . Can I dispatch request object to Servlets ? I know we can dispacth request objects to JSP views ? Is it the same ?


Thank ou for your answers...
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) local variables in doGet and doPost are thread safe as they are created every time the methods are called

2) Yes you can dispatch request using request dispatcher. I think what you are trying to say here is that can you pass an attribute between servlets using request dispatching. The answer to that is yes...
 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit you have cleared my doubt
 
Poop goes in a willow feeder. Wipe with this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!