Monday, October 17, 2011

"Redirection" after "dsp:include" wont work in ATG.

Normally in J2EE, we can redirect to another page after  any "include" in the page.

For example this will work
<@include page="test2.jsp"/>
  <jsp:forward page="test3.jsp"/>
or
<jsp:include page="test2.jsp"/>
<jsp:forward page="test3.jsp"/>

But once you have dsp:include in page, you will not be able to redirect to any other page using any redirection operation like "Redirect" droplet or "jsp:forward" or request dispatcher etc.

For example:
test1.jsp
<%@ taglib uri="dsp" prefix="dsp"%>
<dsp:page>
   I am in test1.jsp <br>

  <%-- including test2.jsp --%>
  <dsp:include page="test2.jsp"/>
 
  <%-- redirect to page test3.jsp --%>
  <dsp:droplet name="/atg/dynamo/droplet/Redirect">
    <dsp:param name="url" value="test3.jsp"/>
  </dsp:droplet>

  end of test1.jsp <br>
</dsp:page>
test2.jsp
<%@ taglib uri="dsp" prefix="dsp"%>
<dsp:page>
 I am in test2.jsp <br>
</dsp:page>
test3.jsp
<%@ taglib uri="dsp" prefix="dsp"%>
<dsp:page>
  I am in test3.jsp <br>
</dsp:page>
if you access http://localhost:8080/test1.jsp
output -
I am in test1.jsp
I am in test2.jsp
end of test1.jsp
 If you remove " <dsp:include page="test2.jsp"/>" in test1.jsp and
access http://localhost:8080/test1.jsp
you will be redirected to test3.jsp
I am in test3.jsp
If you use jsp:include or @include instead of dsp:include like below
  <jsp:include page="test2.jsp"/>
  <dsp:droplet name="/atg/dynamo/droplet/Redirect">
    <dsp:param name="url" value="test3.jsp"/>
  </dsp:droplet>
You will be redirected to test3.jsp. 

9 comments:

  1. Thanks for the tip, I'm unaware of this till this date. Will keep in mind! Thanks!

    ReplyDelete
  2. Even i am too not aware of this, Thank you for the information.

    ReplyDelete
  3. very good one....very userfull when ve perform transient check in profile....Redirection droplet

    ReplyDelete
  4. very nice pls update these type of small defects in the future

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. but when we have prams to send to other page jsp:include is not working . can you please help out.
    < jsp:include page="/account/gadgets/review-item-link.jsp" >
    < jsp:param name="productId" value="${orderLine.itemStyle}" />
    < /jsp:include>

    ReplyDelete
  7. Suffered half a day today because of this.

    ReplyDelete