| Author |
RequestDispatcher & forward method
|
Saurabh Saha
Ranch Hand
Joined: Dec 08, 2004
Posts: 52
|
|
Hi, Please tell me what is the difference between RequestDispather and <jsp:forward > method. I know that we use these two method to forward a request to any other page within the context. I want to know which is better approach to use RequestDispatcher or <jsp:forward > Thanks, Saurabh
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
JSP forward gets translated into requestDispatcher when the JSP is converted to servlet code.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Saurabh Saha
Ranch Hand
Joined: Dec 08, 2004
Posts: 52
|
|
Thanks Ben, It means using RequestDispatcher is better than <jsp:forward >, please correct me, if I'm wrong.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
No, it means it's exactly the same. <jsp:forward > will be translated into requestDispatcher.forward in the generated servlet code. If I were going to forward from a JSP (which I never do) I would use <jsp:forward> because it's cleaner looking than putting a scriptlet in my JSP code. Performance-wise, there is absolutely no difference.
|
 |
Saurabh Saha
Ranch Hand
Joined: Dec 08, 2004
Posts: 52
|
|
Thanks Ben, Now it's clear to me.
|
 |
 |
|
|
subject: RequestDispatcher & forward method
|
|
|