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 servlet chaining?
What is ServletContext object?
Explain the steps involved in placing a servlet within a package?
What is the purpose of inter-servlet communication?
What is servlet name in web xml?
Can you refresh servlet in client and server-side automatically?
What is the use of welcome-file-list?
What is servlet in web technology?
What is the procedure of invoking different servlet in a different application?
What is the difference between a generic servlet and http servlet?
When should you prefer to use doget() over dopost()?
How a servlet is unloaded?
Which http method is said to be non-idempotent and idempotent?
What are all the protocols supported by httpservlet?
What is the capacity the doget can send to the server?