| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
XyzWs JSP FAQ:
Are implicit objects in JSP are thread safe?
Printer-friendly version |
Mail this to a friend
|
Advertisement
|
Are implicit objects in JSP are thread safe?
It's important to note, though, that if you store objects in the
Although the For example, if you create a completely new object in the method, and place it in the request context, it will be threadsafe:
<%
String name = new String("Kevin");
request.setAttribute("user", name);
%>
If you use an existing object which is also present in one of the unsafe contexts (application or session), it will not be threadsafe:
<%
String name = (String)session.getAttribute("name");
request.setAttribute("user", name);
%>
If you use an existing object which is a static (class) or member (instance) variable in the servlet class, it will not be threadsafe:
<%!
String name = (String)session.getAttribute("name");
%>
<%
request.setAttribute("user", name);
%>
|