difference between sendredirect,forward and url rewritting

Answers were Sorted based on User's Feedback



difference between sendredirect,forward and url rewritting..

Answer / md. abid hossain

Both SendRedirect and forward is used to forward the
request to another resource. In case of forward() container
does not report to the browser,it is happend within the
container..so objects which are stored in request is not
lost..bt in sendredirect coantainer report to browser and a
new url is displayed..so objects which are stored in
request is lost..
URL rewriting is technique of session tracking.

Is This Answer Correct ?    14 Yes 1 No

difference between sendredirect,forward and url rewritting..

Answer / ravikiran

forward is a teqnique used to delegate the response to a new
resource and happens on the server side.And we cann't
forward a response to a resource residing on different machine.
Sendrediredt is the techinque used to delegate the response to
other webapplication,which may reside on different machine
as well.
Url rewriting is a technique used for session tracking when
the cookies are disabled,to transfer the session id back and
forth between the clent and the server

Is This Answer Correct ?    7 Yes 2 No

difference between sendredirect,forward and url rewritting..

Answer / chandra kunchala

SendRedirect():

1.
this is used to transform the request from one
container to another or from one web-application to another
or with in the web-application also
This happens at client side. this will applicable in
the same container as well as different container which are
located in different places.
2.
when ever browser sending the request to the
server. but that server is responsible to provide the
response for that request then that server delegates that
reuest(re-direct) to the same client with status code:302
and location of other server in which where we can get the
actual response fot that request.
3.
By seeing that status code:302, the browser creates
another request object and send to the another
servlet(anothere servlet) which is by seeing in location
header that was send by the first server.
4.
then the second server will responsible to generate the
actual response fot that request.

5.
here the request comes back to the cleint foa making
another request to another server right? so, there may be
chanse of traffic problems in the transimittin the request
or response.

6.
performance will automaticall reduce.
7.

after commiting the response to the client, we are
not allowed to use response.sendRedirect() method. if we are
use that, we will get RuntimeException saying
illegalStateException.
we can see on browser addressbar with new address of the
second server (servlet)
now.... forward():
1.
this is also used forward the request from one place
to another but it should be in the same web-container.
2.
it will happens at server side.
performance will increase compared to sendRedirect()
3.
after committing the response we are not forward the
request to another like sendRedirect()..

Is This Answer Correct ?    3 Yes 2 No

difference between sendredirect,forward and url rewritting..

Answer / kalyan

Forward () method is bypass the client request one class to
another class using forward(request ,response) method it
done on the serverside.

sendredirect is changing one page to another page its a
default page its done the client side.

Is This Answer Correct ?    0 Yes 1 No

difference between sendredirect,forward and url rewritting..

Answer / ravikiran.chd

sendRedirect will happen on the client side,forward will
happen on the server side,url rewriting will happen by the
browser to do session tracking when the cookies are disabled
by calling response.encodeURL(/abc) or
reponse.encodeRedirectURL(/abc)

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Servlets Interview Questions

What are the life cycle methods of a servlet?

0 Answers  


Is it possible to have a constructor inside the servlet?

0 Answers  


difference between request.getSession(false) or request.getSession() and request.getSession(true)

2 Answers  


What is http servlet?

0 Answers  


Why servlet is used as controller ? Not JSP? I want complete explation?

0 Answers   Tech Mahindra,


Hi friends am newbie to servlet. How code reusability easy in servlet. why not in jsp . here reusabillity means only javabeans or any thing else.

1 Answers  


What is servlet interface?

0 Answers  


Hi friends, am newbie to servlet. My interviewer asked why used servlet in your application. i used servlet for controller logic and business logic . is it correct ?

5 Answers   TCS,


Hi frnds iam new to Java Kindy any one can provide or me Servlets Example code and can explain to me flow of servlets and as Jsp and Struts and provide to me some sample example on these 3 topic flow,code example,and tutorials,and related websites which i can refer....thanks in advance..........

3 Answers  


can we use more than one controller in web application

3 Answers   IBM,


If you want to modify the servlet,will the Webserver need to be ShutDown ?

9 Answers  


Explain the servlet context.

0 Answers  


Categories