| Author |
sendRedirect() Vs. include() Vs. forward()
|
Rajasekhar Karanam
Greenhorn
Joined: Sep 18, 2011
Posts: 13
|
|
Guys, Please make me clear about these topics in Servlets.
|
 |
ntumba lobo
Ranch Hand
Joined: Oct 21, 2008
Posts: 179
|
|
sendRedirect(myUrl1) : you are sending back a response to the client and asking the browser to make a new request with the provided url, here myUrl1
include() : Say in servletA you call include(/path/to/myView.jsp) : you are asking the web container to include in the response of servletA the response of myView.jsp.
ServletA is in control, I mean responsible for generating the response to the client and you just include as well the response of another web component (e.g jsp)
forward() : say in servletA you call forward(path/to/myView.jsp): here servletA passes the control to myView.jsp to generated the response to the client. The client will see only the content from myView.jsp nothing from servletA.
I hope that helps
|
SCJP 5 , SCWCD 5, SCEA 5
|
 |
 |
|
|
subject: sendRedirect() Vs. include() Vs. forward()
|
|
|