Could you please tell me whether this
servlet would be thread-safe?
import javax.servlet.*;
import javax.servlet.http.*:
import java.io.*;
public class TestServ extends HttpServlet implements SingleThreadModel
{
String index;
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
response.setContentType("text/plain");
PrintWriter out = res.getWriter();
myName = req.getParameter("value");
doFunction(out);
out.close();
}
public void doFunction(PrintWriter out)
{
out.println(index);
}
}
-----------
I think it would be because although a class variable index is used, it is called and initialized in the service method.
However, if there was another function in the class, and the index variable is maipulated, the servlet would no longer be
thread safe.
is my logic correct?
please reply