hi,
Which statement is TRUE regarding the following code?
Please select one correct answer.
import javax.servlet.*;
import javax.servlet.http.*;
public class MyHttpServlet extends HttpServlet
implements SingleThreadModel {
StringBuffer bufferOne = new StringBuffer(); //1
static StringBuffer bufferTwo = new StringBuffer(); //2
protected void doGet(HttpServletRequest req, //3
HttpServletResponse res) throws java.io.IOException{
HttpSession session = req.getSession(); //4
res.setContentType("text/html");
java.io.PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>This is my
servlet!</title>");
out.println("</head>");
out.println("<body>");
out.println("</body>");
out.println("</html>");
out.close();
}
A.Variable bufferOne at //1 is NOT thread-safe.
B.Variable bufferTwo at //2 is NOT thread-safe
C.Both A and B
D.Variable req at //3 is NOT thread-safe
E.Variable session at //4 is NOT thread-safe
F.Both D and E
I have selected c is the answer, because class variable are not
thread safe.But they tole "B" is the rite answer. anybody please clear this doubt.