I'm not sure exactly what your problem is, but the advice to create a new
object, and then replace it with the one retrieved from the session is
totally unsound. All that will do is to create an extraneous Hashtable
instance that will be garbage collected at some point after replacing the
reference with the one retrieved from the session.
So what exactly happens when you execute the out.println(h); ? A null? What
do you mean by "it fails"?
Be sure you are referencing the same session. If you are doing this in the
same browser, I can't think of how this could go awry, but it's something
to check and get out of the way.
hth,
bear
At 06:26 PM 3/5/2002 +0200, you wrote:
>You must first take a new instance of the hashtable object and then assign
>to it the value of the session variable....
>that is:
>Hashtable h = new Hashtable();
>h = (Hashtable)session.getAttribute("mailMessages");
>
>-----Original Message-----
>From: Shahata, Ashraf [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, March 05, 2002 1:49 PM
>To: [EMAIL PROTECTED]
>Subject: HashMap
>
>
>Hi all,
>I've got the following code that uses the HashMap to pass to a session:
><%
> HashMap messageList = new Hashtable();
> messageList.put("company", "NetEffect");
> messageList.put("company_address", "Oosteinde 1");
> messageList.put("company_city", "Amsterdam");
> session.setAttribute("mailMessages", messageList);
>%>
>
>However, everytime I retrieve it:
><%
> Hashtable h = (Hashtable)session.getAttribute("mailMessages");
> out.println(h);
>%>
>it comes back empty, i.e it fails!! I tried the same with HashTable and it
>works fine with no problems!! Does anyone know if there is any restriction
>with using HashMap in sessions?
>
>Thanks
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
>
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com