Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatch Forward and Include

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unit testing (with the help of Cactus framework) my servlet which contains the line RequestDispatcher.forward(..). In short, I need to manually instantiates my servlet and calls its doGet() with the request/response provided by the framework and verify the required attributes are put in the request when the servlet returns.

However, that comes to the question of what RequestDispatcher.forward() would do to my execution flow. Normally, we're not expected to put in any code after forward(). But in unit testing, our verification would be placed after the servlet call. I checked the API & servlet spec. There is nothing about the execution flow after forward() call. Can anyone clarify on this? Thanks a lot.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this goes beyong the scope of unit testing. It is the container's responsability to leave the request parameters after the forward. If you want to check that parameters are in the request, do it before the forward.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic