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 are the various ways of session supervision in servlets?
What is the use of java servlet api?
Write a servlet to upload file on server.
What is a deployment descriptor?
Can we use threads in Servlets?
Explain Action Servlet?
What if you need to span your transaction across multiple servlet invocations?
How do you deal property files in servlet?
What are all the protocols supported by httpservlet?
Which are the different ways you can communicate between servlets?
Explain jsessionid?
What is string tokenizer?
How do you load an image in a Servlet?
What is servlet mapping?
How to create war file?