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
Discussions
Web tier: servlets, JSP, Web frameworks: is sessions variable and pageContext variable thread safe?
-
is sessions variable and pageContext variable thread safe? (5 messages)
- Posted by: zhang zhang
- Posted on: July 15 2004 11:54 EDT
Threaded Messages (5)
- is sessions variable and pageContext variable thread safe? by Senthil Chinnaiyan on July 15 2004 15:40 EDT
- is sessions variable and pageContext variable thread safe? by zhang zhang on July 15 2004 15:46 EDT
- is sessions variable and pageContext variable thread safe? by Madankumar Neelakantan on July 15 2004 11:46 EDT
- is sessions variable and pageContext variable thread safe? by zhang zhang on July 15 2004 15:46 EDT
- is sessions variable and pageContext variable thread safe? by Rene Zanner on July 16 2004 03:05 EDT
- is sessions variable and pageContext variable thread safe? by zhang zhang on July 16 2004 10:29 EDT
-
is sessions variable and pageContext variable thread safe?[ Go to top ]
- Posted by: Senthil Chinnaiyan
- Posted on: July 15 2004 15:40 EDT
- in response to zhang zhang
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.
Senthil. -
is sessions variable and pageContext variable thread safe?[ Go to top ]
- Posted by: zhang zhang
- Posted on: July 15 2004 15:46 EDT
- in response to Senthil Chinnaiyan
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?
thank you -
is sessions variable and pageContext variable thread safe?[ Go to top ]
- Posted by: Madankumar Neelakantan
- Posted on: July 15 2004 23:46 EDT
- in response to zhang zhang
Hi,
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 ?
-MK. -
is sessions variable and pageContext variable thread safe?[ Go to top ]
- Posted by: Rene Zanner
- Posted on: July 16 2004 03:05 EDT
- in response to zhang zhang
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();
sessionMap.put("key1", session.getAttribute("differentKey1");
...
pageContext.setAttribute("sessionMap", sessionMap);
...
}
Cheers,
René -
is sessions variable and pageContext variable thread safe?[ Go to top ]
- Posted by: zhang zhang
- Posted on: July 16 2004 10:29 EDT
- in response to Rene Zanner
Thank you.
you almost get what I did!
only diffrence is I use HashMap instead of HashTable,is this OK?