As you may already know that sendRedirect method in response object and RequestDispatcher object both are used to redirect to another page in servlets,but both works in a different fashion.
RequestDispatcher forwards the request,response objects to another page/servlet this happens at the server side.
where as sendRedirect method makes a new request from client side but client is unaware of the process.
for example if you say in real time
if X is asking about some information to Y
if Y is confirming with Z and telling you the answer is RequestDispatcher mechanism.
or if Y is telling you that ask Z for that information then that is sendRedirect we can say(but client i.e X is unaware of the process since it is a automated flow of process that hapeens).
By using RequestDispatcher the url in the client browser will be the first page address(i.e Y in example),
in case of sendRedirect it changes to the second page address(i.e Z).
RequestDispatcher forwards the request,response objects to another page/servlet this happens at the server side.
where as sendRedirect method makes a new request from client side but client is unaware of the process.
for example if you say in real time
if X is asking about some information to Y
if Y is confirming with Z and telling you the answer is RequestDispatcher mechanism.
or if Y is telling you that ask Z for that information then that is sendRedirect we can say(but client i.e X is unaware of the process since it is a automated flow of process that hapeens).
By using RequestDispatcher the url in the client browser will be the first page address(i.e Y in example),
in case of sendRedirect it changes to the second page address(i.e Z).