Does RequestDispatcher.forward() return to the caller ?

sampreet kaur chawla

Yes, like any Java method call, RequestDispatcher.forward() returns to the caller.

Hence we should ensure that, the caller should not be using PrintWriter() or getOutputStream() object, as it results in IllegalStateException. Neither should the call be followed by another call of RequestDispatcher.forward() or RequestDispather.include().

[The idea of RequestDispatcher.forward is that the first servlet sets things up, and the second one prints. Unfortunately, that architecture is somewhat limited. If you want both to print, you must use RequestDispatcher.include instead. -Alex]

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact