Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ Ch 5 Mock Exam

 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Chapter 5 mock exam, the answer for question 12 is A, D and E. I don't see why answer D is correct. If you call a Test servlet as:

http://localhost:8080/app/Test/?x=1

In the servlet,

RequestDispatcher rd = request.getRequestDispatcher("/Target?x=2");
rd.forward(request, response);

In the forwarded Target servlet,

request.getQueryString(); // prints "x=2"

The forwarded servlet prints "x=2" instead of the original query string "x=1". So answer D should be incorrect.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I like appreciate for coming up with such a interesting question.

In the request dispatcher you are modifying the original query String with your custom values. thats the reason why you are getting custom values and not original query String.

I think the answer makes more sense without the word Original

 
Edmund Yong
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I think they should put this in the errata.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic