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
request parameter how to find whether a parameter exists in the request object?
Explain session tracking and its importance?
What’s the difference between forward() and sendredirect() methods?
Explain url encoding in servlet?
What is the capacity the doget can send to the server?
What is pure servlet?
How we can create war file in servlet?
Why filter is used in servlet?
What is the difference between the include() and forward() methods?
What are the difference between RMI and Servlets?
how many jsp scripting elements are there and what are those?
How the JSP file will be executed on the Server side?
What’s the use of the servlet wrapper classes??
What is the servlet?
What is the