I'm using JSPs and a custom tag.
in the tag, there are 2 things
1.get sessions variables and put them into a Map.
2.get a remote interface of ejb
the session map and ejb instance are put in pageContext by using pageContext.setAttribut()
also,I defined the class extends TagExtraInfo to get these variables.
in all of jsps ,we use this tag to get sessions variable(from map) and ejb instance to call ejb method.
I just wondering if this is thread safe?I don't want sessions variables shared on web application.thank you
Session Objects are created for each user seperately. How can one user access another user's session object? If you keep it in Application scope, it may be possible. But I think not with session objects.
thank you.session is not shared by others.but my point is that:
in the tag,the session are put in a map,and map is put in pageContext,so that they can be accessed from jsp,my question is if pageContext could be shared by others?
If you are using a "Hashtable" as your Map your objects are already
thread-safe. If you wanna make the entire JSP page threadsafe, do this at the start of the page :-
<%@ page isThreadSafe="false" %>
Could the others confirm this approach ?
Hi zhang zhang,
if your "session map" is not an instance variable of the tag, there should be no problem. I'm assuming you do something like get attributes from the session in the doEndTag() method of your tag like this:
public int doEndtag()
Map sessionMap = new Hashtable();
you almost get what I did!
only diffrence is I use HashMap instead of HashTable,is this OK?