943,521 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 6045
  • JSP RSS
Feb 18th, 2008
0

Session variables

Expand Post »
I have a string stored in a session variable.....how do I get that string back out as I get the error:Type mismatch: cannot convert from Object to String

Is there a toString() method or something?

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
eddy556 is offline Offline
32 posts
since Jan 2008
Feb 20th, 2008
0

Re: Session variables

You will have to cast it to the reference type you are expecting it to return. This is because the specifications say that getAttribute() returns a variable of type Object which of course makes sense since it enables us to store a reference variable of any kind. Maybe something along the lines of:
JSP Syntax (Toggle Plain Text)
  1. session.setAttribute("isLoggedIn", Boolean.TRUE);
  2. Boolean b = (Boolean)session.getAttribute("isLoggedIn");
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Feb 20th, 2008
0

Re: Session variables

Thanks mate I was being stupid....newbie ya see? Lol I figured out by myself, thanks anyway :-)
Reputation Points: 10
Solved Threads: 0
Light Poster
eddy556 is offline Offline
32 posts
since Jan 2008
Feb 20th, 2008
0

Re: Session variables

If you find a solution to a problem, it is recommended that you mark it as solved by clicking the Mark it as solved link, and if possible, posting the solution which worked for you. That way, someone else facing the problem who stumbles upon this thread might find your answer to be useful. I guess this is the least we all can do, can't we? :-)
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: Using md5 in JSP
Next Thread in JSP Forum Timeline: Displaying language other than English on JSP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC