wood burning stoves 2.0*
The moose likes Servlets and the fly likes context.setAttribute (object) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "context.setAttribute (object)" Watch "context.setAttribute (object)" New topic
Author

context.setAttribute (object)

Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Hi all,
I got an question regarding context.setAttribute (object) , for instance :
here i made hashmap then put it as an attribute in the context, my question is , if i changed the "key1" after setting the hashMap in the context , is it will be reflected directly or i need to write context.setAttribute ("hashMap", temp) ; after line 4 ?


Thanks,
Sherif
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
You'll find the answer by printing out the contents of the hash map after the 4th line!


OCJP 6 (93%)
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
The reference to the HashMap now exists in two places - local variable and context, but it is still the same HashMap.

Bill
 
 
subject: context.setAttribute (object)
 
Similar Threads
Hashmap in android
sendRedirect with passing some values.
shllow copy in FastHashMap
HashMap reference
init() questions - confused