Here we will list all the differences between forward() and sendRedirect().
|
Forward
|
SendRedirect
|
|
It’s a method of RequestDispatcher.
|
It’s a method of HttpServletResponse.
|
|
This method is internally handled by container.
|
This method is not internally handling by
container.
|
|
This method doesn’t change the browser URL.
|
This method changes the browser URL.
|
|
Forward sends the same request.
|
SendRedirect always sends the new request.
|
|
It can only send the request with in same
application, or it can only access those resources which are available in
same application.
|
It can send the request with in same application
and outside the application, and can access inside and outside resources of
server.
|
|
It only uses Relative URLs.
|
It uses Absolute URLs.
|
|
It’s a server-side.
|
It’s a client-side.
|
|
Method Signature :
void forward(ServletRequest request,
ServletResponse response);
|
Method Signature :
void sendRedirect(String url);
|
|
Example :
request.getRequestDispathcer("login.jsp").
forward(request, response);
|
Example :
response.sendRedirect("login.jsp")
|
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Java I/O Tutorial

No comments:
Post a Comment