*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getValue() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "getValue() method" Watch "getValue() method" New topic
Author

getValue() method

dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383


This is from HFSJ book. Chapter no:5,page:218. They have written that "the getValue() method returns the OLD value of the attribute if the attribute was replaced." But here old value is "b" for "a". So why it is returning "c"?"c" is the new value. Anybody can explain?


SCJP-1.5<br />SCWCD-1.4
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The API for ServletRequestAttributeEvent#getValue is clear about that :
Returns the value of the attribute that has been added, removed or replaced. If the attribute was added (or bound), this is the value of the attribute. If the attribute was removed (or unbound), this is the value of the removed attribute. If the attribute was replaced, this is the old value of the attribute.

They have written that "the getValue() method returns the OLD value of the attribute if the attribute was replaced

What did you get after : "P:" ? (which is your replace method)

You should have :
A:a->b (set a to b)
P:a->b (replace a by c, so the old value b is printed)
M:a->c (remove a)


[My Blog]
All roads lead to JavaRanch
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Thanks I got it now. Sorry for late reply. But I had not been reading from a couple of days & from today I have started again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getValue() method
 
Similar Threads
page no 218 from KathySierra bookabout attributes
page 218 Head First Servlets and JSP
servlet
Attributes Doubt??
Doubts in Mock exam HFSJ