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 Servlets and explain the advantages of Servlet life cycle?

1037


What is the major difference between servlet and applet?

943


What must be implemented by all servlets?

1041


Why is httpservlet declared abstract?

1058


What are common tasks performed by Servlet Container?

1206


Which application server is best for java?

1020


Explain the role of dispatcherservlet and contextloaderlistener.

1121


Why is init() method is used in servlets?

957


Which interface should be implemented by all servlets?

1164


What are the types of protocols supported by httpservlet ?

1166


How to create war file?

1093


Define context initialization parameters.

984


Why is http protocol called as a stateless protocol?

951


What are all the advantages of servlet over cgi?

1018


Explain web container.

977