aspose file tools*
The moose likes Servlets and the fly likes RequestDispatch Forward and Include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatch Forward and Include" Watch "RequestDispatch Forward and Include" New topic
Author

RequestDispatch Forward and Include

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatch Forward and Include