jsp:forward and RequestDispatcher.forward

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    jsp:forward and RequestDispatcher.forward

    Could anyone tell me what is difference between jsp:forward and RequestDispatch er.forward?

    These two codes behave differently ...

    Code:
    <jsp:forward page="page_ref"/>
    and

    Code:
    request.getRequestDispatcher("page_ref").forward(request,response);
    In first case ...... after getting forwarded the next statements are not getting executed.

    But in second case ..in spite of getting forwarded the next statements are getting executed .....
    Wy?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    The second case is called from a servlet which is a normal Java class so the normal program flow rules of Java apply.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by r035198x
      The second case is called from a servlet which is a normal Java class so the normal program flow rules of Java apply.
      No No ...in both case i am doing in JSP.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        It doesn't matter, it's still a strict Java context and normal Java rules apply.

        P.S Why are you double posting this?

        Comment

        • itsraghz
          New Member
          • Mar 2007
          • 124

          #5
          No, it should NOT run any statements after you have forwarded to a resource.

          Though the jsp:forward and RequestDispatch er.forward() may seem to be different in your perspective, to the container it matters the same. Obtaining a resource and forward the control/request to it. That's all.

          It should/does NOT include the output generated in the resource from where the request is forwarded! Once the control is forwarded, the forwarded resource takes care from then on!
          Last edited by itsraghz; Nov 13 '08, 03:28 PM. Reason: add more details

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by r035198x
            It doesn't matter, it's still a strict Java context and normal Java rules apply.

            P.S Why are you double posting this?
            Sorry i didn't see that ... it was moved ...
            By the way ..thanks for your reply ..
            but ..the thing is ..JSP page ultimately converted into .... Java code then?

            Comment

            Working...