wood burning stoves*
The moose likes Servlets and the fly likes method getAttribute throws exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "method getAttribute throws exception" Watch "method getAttribute throws exception" New topic
Author

method getAttribute throws exception

Vidya S Sreenivasan
Greenhorn

Joined: Jan 28, 2002
Posts: 4
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

Joined: Mar 22, 2002
Posts: 1055
Can you post a simple test case of this?
Vidya S Sreenivasan
Greenhorn

Joined: Jan 28, 2002
Posts: 4
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
 
Consider Paul's rocket mass heater.
 
subject: method getAttribute throws exception
 
Similar Threads
long post IBM.158
Response already committed
doubt about servlets
Help Needed Regarding Session Management
Servlets and Threading