Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Is Servlet Class Thread safe?????? How to make servlet
Thread safe ???

Answer Posted / venkat

by default every servlet is not Thread safe.

if we want to make Thread safe use these statements

1) use SingleThreadModel interface . but this interface is
deprecated in servlet 2.5 specification

2) use synchronized methods and blocks

for example
=========
use synchronized method
=======================


public synchronized void service(ServletRequest
request,ServletResponse response) throws
ServletException,IOException
{
.........
.......
}

use synchronized block
========================


public void service(ServletRequest request,ServletResponse
response) throws ServletException,IOException
{
synchronized(this)
{
.........
.......
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you find out what client machine is making a request to your servlet

1023


If servlet receives multiple requests, how many objects will it create?

1333


What is servletconfig?

984


What is the workflow of a servlet?

1132


How forward () method is different from send redirect () method?

923


What is Request Dispatcher?

1367


How we can get ip address of client in servlet?

945


How native code can be used in a servlet?

4023


How do you run a servlet?

1019


What is session?

1007


Describe servlet?

989


How can an existing session be invalidated?

1105


Why session tracking is needed?

989


Is servlet a framework?

993


Which HTTP method is non-idempotent?

1072