What is difference between Forward() and sendRedirect()
methode?
Answers were Sorted based on User's Feedback
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 |
Answer / farhaananwar
Foward action is done at server site without interference of
web browser even the old URL is not changed whereas request
is forwarded to new resource hence forward action is faster
than redirect action. when forward operation is performed
request attributes and session attributes persists.
In case of redirection. servlet container sends the
response to clien web browser by setting status to
HttpServletResponse.SC_TEMPORARY_REDIRECT and location
header
to the new URL address where browser will have to redirect
new request automattically without interference of client.
when browser redirect new request to resource, the URL in
web browser changed. This proccess is slower than forward
because server send response to browser telling that
resource requested is moved temporary to other resource and
need redirction and then browser take action. The request
paramters are persist in new redirect request.
Is This Answer Correct ? | 1 Yes | 3 No |
Answer / lala mishra
i will tell the conclusion of all
1. in case of forword() server will not inform client
2. in case of forword the same request will be sent to other
resourse so that request attribute will not distroy.
the opposite is for sendRedirect.
Is This Answer Correct ? | 0 Yes | 4 No |
Answer / farhaananwar
Foward action is done at server site without interference of
web browser even the old URL is not changed whereas request
is forwarded to new resource hence forward action is faster
than redirect action. when forward operation is performed
request attributes and session attributes persists.
In case of redirection. servlet container sends the
response to clien web browser by setting status to
HttpServletRequest.SC_TEMPORARY_REDIRECT and location header
to the new URL address where browser will have to redirect
new request automattically without interference of client.
when browser redirect new request to resource, the URL in
web browser changed. This proccess is slower than forward
because server send response to browser telling that
resource requested is moved temporary to other resource and
need redirction and then browser take action. The request
paramters are persist in new redirect request.
Is This Answer Correct ? | 1 Yes | 7 No |
What are common tasks performed by Servlet Container?
Given the request path below, which are context path, servlet path and path info? /bookstore/education/index.html
difference between sendredirect,forward and url rewritting
What do you understand by mime type?
How can you use a servlet to generate a plain text instead of html?
What is a web application and what is it’s directory structure?
What is the importance of init() method in Servlet ?
What do you mean by httpservlet?
How the servlet is loaded?
what is meant by Transaction Isolation Levels?
Explain in detail about applet to servlet communication?
What is lazy loading and what is Generic Servlet Class?