This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "context.setAttribute (object)" Watch "context.setAttribute (object)" New topic

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 ?

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

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

Consider Paul's rocket mass heater.
subject: context.setAttribute (object)
Similar Threads
Hashmap in android
sendRedirect with passing some values.
shllow copy in FastHashMap
HashMap reference
init() questions - confused