5

I'm implementing DD4T on Java. To implement common layout, like header and footer etc., I write "jsp:include" on page template JSP file. But apparently it includes the page itself, and the page is included again and again, and causes infinite loop. This problem occures even when page name is not correct like following.

<jsp:include page="xxxx.html"></jsp:include>

Of cause, same problem occurs when page name is correct.

What is good way to include common layout on Java DD4T?

Regards,

2
  • 1
    What if you unplug DD4T and Tridion for a regular dynamic java web app, how would you solve this problem then? Commented May 25, 2015 at 12:08
  • It turned out that this is a problem of DymanicPageController's logic. It always gets requested URL by request.getRequestURI(). But when the page is included by jsp:include directive, it has to get URL by request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE). Commented Jun 16, 2015 at 0:25

3 Answers 3

3

In your master layout (or page layout), you should use the DD4T method to render dynamic component presentation (that's what we use in our c# based razor views and assuming you should be able to do the same in Java as well). This is assuming you have created Header, footer etc as dynamic components since they are included on multiple pages and you don't want to republish all pages when you make changes to your component. Here is the DD4T Java implementation link where you can find methods to use: DD4T Java GitHub

2

As suggested by Vipin, you should use dynamic components for common layout so that while changing any part of common layout you don't need to publish all the pages only publishing dynamic component is sufficient.

The possible implementation for JSP to include dynamic components is given in the answer for the following question: Render dynamic component presentation

1

This is a known limitation in Spring MVC. They way I've solved it, is expressed in the taglib class below:

https://github.com/dd4t/dd4t-2-java/blob/develop/dd4t-mvc-support/src/main/java/org/dd4t/mvc/tags/SmartIncludeTag.java

You can use it to include common shared pages, like header and footer pages published from Tridion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.