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 ? | 5 Yes | 0 No |
Post New Answer View All Answers
Is servlet a controller?
What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?
What is the difference between a generic servlet and http servlet?
Can you use javascript in servlets?
How can we perform any action at the time of deploying the project?
What is servletconfig?
How to commuincate between an applet and a servlet?
What is the purpose of dispatcherservlet properties?
how the HTML data stored in web server?
Why is servlet used?
How is a servlet implemented in code?
What is servlet api used for conneting database?
What is SingleThreadModel interface?
Name the packages that work with servlet?
Why is httpservlet declared abstract?