What is difference between Forward() and sendRedirect()
methode?

Answers were Sorted based on User's Feedback



What is difference between Forward() and sendRedirect() methode?..

Answer / shakir khan

The RequestDispatcher forward and include methods are
internal to a servlet container and does not affect the
public url of the webresource.

forward() are excute on the server side.

when a forward() is invoked,the request is sent to another
resource on the server without the client being inform that
a different resource is going to process the request.This
occurs completely with in the webcontainer.

sendRedirect() excutes on the client side.

When a sendRedirect()is invoked,it causes the webcontainer
return to the browser,indicating that a new url should be
requested because the browser issues a completely new
request,any object that are stored as request attributes
before the redirect occurs will be lost.
This extra round trip,a redirect is slower than forward.

Is This Answer Correct ?    45 Yes 3 No

What is difference between Forward() and sendRedirect() methode?..

Answer / jack

In the case of forward() the server will redirect to the
next page but in the case of sendRedirct() the server will
inform the browser to redirect the url to the next page.

Is This Answer Correct ?    43 Yes 2 No

What is difference between Forward() and sendRedirect() methode?..

Answer / kishore m

the main diff b/w forward and send redirect is forward is
done at serverside where as send redirect is done at
clientside.

Is This Answer Correct ?    20 Yes 0 No

What is difference between Forward() and sendRedirect() methode?..

Answer / abilash

more over the above answers forward will carry the same
request to the new page.So we can get the values stored in
request.

while in sendRedirect it won't have the same request.

Is This Answer Correct ?    12 Yes 2 No

What is difference between Forward() and sendRedirect() methode?..

Answer / mohan

I want to add one more point to the above answers, that is,
in case of Forward() the attributes related to the request
will remain same, as it is inside the server, whereas
incase of senRedirect(), it results in a new request so the
previous attributes of the request will be lost...

Is This Answer Correct ?    6 Yes 0 No

What is difference between Forward() and sendRedirect() methode?..

Answer / ravikiran.chd

forward happens on server side,sendredirect happens at
client side

Is This Answer Correct ?    3 Yes 0 No

What is difference between Forward() and sendRedirect() methode?..

Answer / raghunath bj

Jsp forward will be used to send some sort of response to
any webresource (it can be a servlet or a jsp) and
sendRedirect will be used in the case of response to be
sent to the next view or Jsp.

Is This Answer Correct ?    2 Yes 1 No

What is difference between Forward() and sendRedirect() methode?..

Answer / n.muthukumar

sendRedirect() sends a redirect response back to the
client's browser.
forward() does not involve the client's browser.
The forward( ) is faster than Sendredirect( ).
RequestDispatcher.forward( ) works on the Server.

when you use send redirect it will rediredct the url to new
url and It will be displayed in browser.
response.sendRedirect(http://162.1.1.0/error.html);

When you use forward it will forward to particular page but
in browser forwarded url won't dispaly
<jsp:forward page http://162.1.1.0/error.html) />

Is This Answer Correct ?    1 Yes 0 No

What is difference between Forward() and sendRedirect() methode?..

Answer / sambasiva

Forward()

->Forward Method is available in RequestDispatcher which is
used to forward the request one component to another web
component which are available in same application
->Forward Method will happen completely on the ServerSide
->When u forwarding the request u can send the data from one
component to another component by attaching to request as an
attribute.
sendRedirect()

->This method available in HttpServletResponse which is used
to send the request from one component to another component
which are available in different application
->sendReddirect will happen both on client side or server side
->when u sendredirect the request u can send the data from
one component to another component as a query string.

Is This Answer Correct ?    0 Yes 0 No

What is difference between Forward() and sendRedirect() methode?..

Answer / venkat

forward() method send source prg to target web resource prg
in same web application.and use source and target web
resource prg are use same req,res objects so will use data
in target web resource prg.

rd.forward(req,res)

sendRedirect() method send source web resource prg to target
web resource prg in same webapplication or two different web
applications in same server or different servers.and this
method will not use same req,res objects so if you want to
send data source to target web resource prg use query
string.

r.sendRedirect("srv2"?a=10);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Servlets Interview Questions

Differentiate between the print writer and servlet output stream?

0 Answers  


How do you deal property files in servlet?

0 Answers  


what are the way a client can be tracked?

3 Answers   ABC, IBM,


Which event is fired at the time of project deployment and undeployment?

0 Answers  


Can a jsp be called using a servlet?

0 Answers  






How servlets are deployed in java?

0 Answers  


Describe the phases of servlet lifecycle?

0 Answers  


What is a java servlet?

0 Answers  


Write a program to show the functionality of servlets.

0 Answers  


What are the classes and interfaces for servlets?

4 Answers  


java.lang.IllegalArgumentException: The path of an ForwardConfig cannot be null while working with struts it displayed pls very ungent

3 Answers   IBM,


What is the purpose of dispatcherservlet properties?

0 Answers  


Categories