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 the difference between forward () and sendredirect () functions in servlet? Explain
What is cgi?
What must be implemented by all servlets?
Is servlet a framework?
What is the use of request dispatcher interface?
What is lazy loading and what is Generic Servlet Class?
How many servlet objects are created?
How to get the actual path of servlet in server?
What is difference between PrintWriter and ServletOutputStream?
What is the difference between CGI and Servlet?
How we can call a jsp from the servlet?
What is Servlets and explain the advantages of Servlet life cycle?
What is difference between get and post method?
What is Servlet API used for connecting database?
What are the phases of a servlet life cycle?