Difference between Include, Forward and sendRedirect in
Servlet?
Answer Posted / md.farookh.mb
Response.sendRedirect () This function is used, when we
want to redirect
the client request to some other site (i.e out of our
context) or
when ever we want to redirect errors. If you are using
sendRedirect (), then it will be visible to the client that
means the URL which you have been redirected will be
visible in the address bar. Redirect response to the client
using the specified redirect location URL.
RequestDispatcher Interface:
Forward() : This can be done in two ways by Request &
ServeletContext.
Forwarding a request from a servlet to another resource
(servlet, JSP
file, or HTML file) on the server. Forward is done at
server side, without the client's knowledge.
When you invoke a forward request, the request is sent to
another
resource on the server, without the client being informed
that a
different resource is going to process the request. This
process occurs
completely with in the web container. When a sendRedirtect
method is
invoked, it causes the web container to 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.
Include:Includes dynamic page information..
| Is This Answer Correct ? | 130 Yes | 15 No |
Post New Answer View All Answers
How do you deal property files in servlet?
What is servlet and list its types?
What is the life-cycle of servlets?
How native code can be used in a servlet?
What is the use of servlet context?
What are the important functions of filters?
Explain servlet events?
When a servlet accepts a call from a client, it receives two objects. What are they?
What is the use of java servlet api?
What is servlet and its advantages?
what is servlet chaining?
What is a servlet context?
What is the directory structure of a war file?
What are the mechanisms used by a servlet container for maintaining session information?
How does tomcat servlet container work?