posted 19 years ago
Greetings,
I am struggling with Question 8 in the mock exam on that page. I think I am confused about the logical flow of the code. The answer is:
A:a->b P:a->b M:a->c
The code looks like:
...
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException {
req.setAttribute("a", "b");
req.setAttribute("a.", "c");
req.removeAttribute("a");
}
public void attributeAdded(ServletRequestAttributeEvent ev) {
System.out.print(" A:" + ev.getName() + "->" + ev.getValue());
}
public void attributeRemoved(ServletRequestAttributeEvent ev) {
System.out.print(" M:" + ev.getName() + "->" + ev.getValue());
}
public void attributeReplaced(ServletRequestAttributeEvent ev) {
System.out.print(" P:" + ev.getName() + "->" + ev.getValue());
}
If anyone can give me hint I would appreciate it. The book does say, "Tricky! The getValue method retuns the OLD value of the attribute if the attribute was replaced." I'll continue to plow ahead but as I said your guidance is appreciated.
Thank you.
Sincerely,
Jerry Bustamente