This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Some help with a sample SCWCD question based on Listeners. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Some help with a sample SCWCD question based on Listeners." Watch "Some help with a sample SCWCD question based on Listeners." New topic
Author

Some help with a sample SCWCD question based on Listeners.

Abhijit Ghatnekar
Greenhorn

Joined: Nov 10, 2007
Posts: 19
Hi All,

I'm very much confused by the following question and it's answer. It's a program actually.

Assume the below to be a valid HTTP Servlet that has been registered with a HTTPServletRequestAttribute Listener class.



And the output is this..

=======================
A:a->b P:a->b M:a->c
=====================

Now how is it that we get the old value of the attribute "a" even if we replace the value of the attribute a?
Is there a way, I could get the new, latest value of "a" the moment it is replaced? This could lead to a potential bug in a production code, not sure why it has to work like this.

Any thoughts?

Regds,
Abhijit.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4907
    
  10

Please QuoteYourSources


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Ankur Gargg
Ranch Hand

Joined: Sep 11, 2011
Posts: 55

HI

You can use ev.getServletRequest().getAttribute("a") to get the new value thus the getValue() method has been coded to return the old value.


Regards
Ankur Garg



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some help with a sample SCWCD question based on Listeners.
 
Similar Threads
Doubts in Mock exam HFSJ
Attributes Doubt??
Doubt on Listeners in HFSJ-Page 212
servlet
page 218 Head First Servlets and JSP