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
How do you find out what client machine is making a request to your servlet
If servlet receives multiple requests, how many objects will it create?
What is servletconfig?
What is the workflow of a servlet?
How forward () method is different from send redirect () method?
What is Request Dispatcher?
How we can get ip address of client in servlet?
How native code can be used in a servlet?
How do you run a servlet?
What is session?
Describe servlet?
How can an existing session be invalidated?
Why session tracking is needed?
Is servlet a framework?
Which HTTP method is non-idempotent?