• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

Explain about forward() method of the Request Dispatcher ?

The forward() method of the RequestDispatcher interface may be called by the calling Servlet only when no output has been committed to the Client. If output data exists in the response buffer that has not been committed, the content must be cleared before the target Servlet's service() method is called. If the response has been committed, an IllegalStateException must be thrown.

forward() should be called before the response has been committed to the Client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward.

We can get only the response from the called Servlet's response only. That is forward() discards the called Servlet's response.