| Author |
Attributes Doubt??
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hi Guys, I'm not able to understand the following question from the HFSJ book!, public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException{ req.setAttribute("a", "b"); req.setAttribute("a", "c"); req.setAttribute("a"); } public void attributeAdded(ServletRequestAttributeEvent ev){ System.out.println("A:" + ev.getName() + "->" + ev.getValue()); } public void attributeAdded(ServletRequestAttributeEvent ev){ System.out.println("M:" + ev.getName() + "->" + ev.getValue()); } public void attributeAdded(ServletRequestAttributeEvent ev){ System.out.println("P:" + ev.getName() + "->" + ev.getValue()); } How will this print A:a->b P:a->b M:a->c?? Please help me guys?? Thanks in advance!
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Micheal John
Ranch Hand
Joined: Nov 01, 2006
Posts: 344
|
|
If your are taking from HFSJ, then It should be like this: NO surprise in the o/p: First your adding the attribute so A:a->b Then your replacing the value for the same attribute "a", so P:a->b Finally removing.. I think the problem for you is with P:a->b instead of P:a->c..the getValue() method returns the old value of the attribute if the attribute was replaced [ January 06, 2007: Message edited by: Micheal John ]
|
Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Michael, Thanks for the help, I was dubious about the way attributes work with respect to the above question. Could you tell me where I can find a suitable explanation for the question given on that page in the HFSJ book??
|
 |
 |
|
|
subject: Attributes Doubt??
|
|
|