This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method getAttribute throws exception

 
Vidya S Sreenivasan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to get an attribute from the session
using (String)session.getAttribute("Name"); and the servlet throws an exception

"Server caught unhandled exception from servlet �TestServlet�: Method ( getAttribute ) invoked on HttpSession object from a thread other than the thread on which the servlet's service method was dispatched."
com.ibm.servlet.engine.webapp.UncaughtServletException: Server caught unhandled exception from servlet �TestServlet�: Method ( getAttribute ) invoked on HttpSession object from a thread other than the thread on which the servlet's service method was dispatched.
How do I solve this ?
I am using Websphere 3.5 .
Any help would be appreciated.
Thanks in advance.
Vidya
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post a simple test case of this?
 
Vidya S Sreenivasan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The problem no more exists. I think the problem was , I wasn't getting the existing session.
This is my code in the jsp page :
I have a javascript method :

I replaced session.getAttribute("NAME") with request.getSession(true).getAttribute("NAME")
and I don't get the exception.
I guess, the first time, it was trying to create another session object rather than using the existing one(using another thread ?)
Am I right? Any pointers are welcome.
I would appreciate it if someone could explain what was going on .
Thanks again.
Vidya.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I can imagine that happening would be if you kept a reference to the session as an instance variable and tried to use that from a different Thread.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic