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

What is the difference between the include() and forward() methods?

1084


What is the difference between genericservlet and httpservlet

1095


What are the types of an http request?

1158


Explain the jar and war files in servlet?

1104


what is multiple server?

2313


Is servlet synchronized?

1089


What are all the protocols supported by httpservlet?

1282


Does servlet have main method?

1190


What is servlet mapping?

1026


What is the effective way to make sure all the servlets are accessible only when user has a valid session?

1062


How can we invoke another servlet in a different application?

1217


What are the life cycle methods of a servlet?

1054


What is the workflow of a servlet?

1181


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

1062


How to rectify errors in java servlet while compilation?

962