Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a web application and what is it’s directory structure?

1027


Write all the phases defined in servlet life cycle?

1056


What is generic servlet class?

1010


Define servlet mapping?

1111


What are all the protocols supported by httpservlet?

1185


What is servlet api used for conneting database?

1171


What is the life-cycle of servlets?

1090


How to get the current httpsession object?

1072


What is the difference between the include() and forward() methods?

1028


Define the lifecycle for executing a jsp page.

1036


What is http servlet?

1016


What is the difference between encodeRedirectUrl and encodeURL?

1062


What is the requirement of servlet config and servlet context implemented and how are they implemented?

942


What is servlet container. how it works?

1088


How to read request headers from servlets?

997