Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

session jsp:useBean  RSS feed

 
john guthrie
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my understanding is that:
<jsp:useBean class="somepackage.SomeBean" id="sessionData" scope="session"/>
will create a variable in the _jspService method named "sessionData". from looking at the code tomcat generated (yeah, i have toyed with this a little) it looks like the servelt tries to set the sessionData variable to an attribute already in the session, which is what i want. the part i am not so happy about is that it re-uses the id as the session key, a la:
sessionData = (SomeBean) PageContext.getSession().getAttribute("sessionData");
i'd like to be able to specify something else as the attribute key. is that possible?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is how it works and it should work that way!
 
john guthrie
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do you say "it should work that way"? i typically use strings for session keys that would make poor variable names, a la:
SomeBean sessionData = (SomeBean) PageContext.getSession().getAttribute("__SESSION_DATA__");
less chance of name clashes...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!