Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

August 26, 2010

RequestDispatcher : forward()

The argument to forward method is the name of the resource we want the request to be forwarded to. This can be a jsp file or a Servlet. In case it is a servlet, the argument should be whatever we have specified in the url-pattern for that servlet declaration in web.xml.

So, the point to be noted here is that in case we want to forward the request to some other servlet, the argument to forward method should be the url-pattern of that servlet.

Also, as we (probably) already know, the URL in the browser is not changed in case of forward. i.e. the client does not get to know that internally the request has been forwarded to some other resource.

No comments: