|
public class TestThreadServlet extends HttpServlet {
private static ThreadLocal thread = new ThreadLocal();
private int flag = 0;
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
flag++;
String str = "This is the first String." + new Object();
if (thread.get() == null)
thread.set(str);
PrintWriter out = response.getWriter();
out.println("<p>");
out.println("<BR>flag : " + flag);
out.println("<BR>sessionid : " + request.getSession().getId());
out.println("<BR>servlet : " + this.toString());
out.println("<BR>thread : " + thread.get());
out.println("</p>");
}
}
|