difference between forward and sendredirect
Answer Posted / srinu
FORWARD----->
1) in Forward request and response object be same.
2)IN FORWARD METHOD THE CONTROLLER DIRECTLY GOES TO OTHER
PAGE WHEN U CALL THE FORWARD METHOD.
3)FORWARD METHOD USED WITH IN WEBAPPLICATION .
4)In this case controller goes directly go to request
page.i.e means does not generated implict reponse go to
browser.
5)U CALL THE FORWARD METHOD JUST NEDDED OBJECT OF
REQUESTDISPACTHER OBJECT
EX:-
RequestDispacher rd=null;
rd = req.getRequestDispatcher("/WA1");
rd.forward(req,res);
5)it used small webapplication.
sendredirect:-
1)in sendRedirect()request,reponse object will not be same.
2)in sendRedirect()method the controller did not pass directly.
3)it over come the drawback of forward()(just watch 3 step
in forward()) this method used with in webapplication or
outside of webapplication.
4)In this case first controller goes client browser window
after it will go to request page.i.e means implict reponse
go to browser.
5)u call the sendRedirect() method u need a response object.
EX:-
response.sendRedirect("/ServletProject/ValidUser");
| Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers
What is a web application and what is it’s directory structure?
Write all the phases defined in servlet life cycle?
What is generic servlet class?
Define servlet mapping?
What are all the protocols supported by httpservlet?
What is servlet api used for conneting database?
What is the life-cycle of servlets?
How to get the current httpsession object?
What is the difference between the include() and forward() methods?
Define the lifecycle for executing a jsp page.
What is http servlet?
What is the difference between encodeRedirectUrl and encodeURL?
What is the requirement of servlet config and servlet context implemented and how are they implemented?
What is servlet container. how it works?
How to read request headers from servlets?