2

Both the ComponentPresentationAssembler classes from the com.tridion.dynamiccontent package, or the deprecated com.tridion.web.jsp package return the content of the dynmamic component presentation as-is, i.e. without the executed Java code. The Java code is displayed in the HTML source.

Example code from a test.jsp page:

<%
com.tridion.web.jsp.JSPPage webPage = 
    new com.tridion.web.jsp.JSPPage(pageContext, "tcm:127-243236-64");

com.tridion.web.jsp.ComponentPresentationAssembler webAssembler = 
    new com.tridion.web.jsp.ComponentPresentationAssembler(webPage);

String title = webAssembler.getContent(455985, 243136);
out.print("Title = " + title + "<br>");

String content = webAssembler.getContent("tcm:127-455985", "tcm:127-243135-32");
out.print("Content = " + content + "<br>");
%>

Example code (2) from a test.jsp page:

<%
com.tridion.web.jsp.JSPPage webPage = 
    new com.tridion.web.jsp.JSPPage(pageContext, "tcm:127-243236-64");

com.tridion.dynamiccontent.ComponentPresentationAssembler dynamicAssembler = 
    new com.tridion.dynamiccontent.ComponentPresentationAssembler(webPage);

String title = dynamicAssembler.getContent(455985, 243136);
out.print("Title = " + title + "<br>");

String content = dynamicAssembler.getContent("tcm:127-455985", "tcm:127-243135-32");
out.print("Content = " + content + "<br>");

// poging 2
dynamicAssembler = new com.tridion.dynamiccontent.ComponentPresentationAssembler(
    "tcm:0-127-1", application, request, response);
%>

The HTML source displays the content of the componentpresentation as well as the Java code from the template itself.

Tridion 2011 SP1 is used together with Tomcat and a working/configured Content Delivery. Publication target language is set to JSP. Dynamic Component Template has checked "Allow on Page Using Dynamic Assembly".

Logfiles doesn't show any warnings or errors except:

2013-10-21 12:18:24,625 WARN Admin - WAI: Could not find a presentation for SiteIdentifier[Protocol=http; Domain=localhost; Port=8080; Path=/tridion.jsp]

Update

DCP's are indeed stored in a broker database (Oracle)

Update 2

Both Publication target and Template Output is set to REL. Unpublished the templates, checked that no CP's are in DB. Republished the templates, but CP's still display Java code.

Added the TLD stuff as suggested below, restarted Tomcat, but same problem. CP's still display unexecuted Java code.

Update 3 (2013-10-23):

Reconfigured to publish the DCP's to the filesystem, same result. JSP code (above) displays HTML and unexecuted Javacode.

I ask myself, if there is configuration missing, one that instructs Tridion to use a JSP CP class instead of a plan CP class impl.

1
  • You can keep the pages on JSP and move just the DCPs to REL (by setting the output format parameter in the CT).
    – Nuno Linhares
    Commented Oct 22, 2013 at 12:37

3 Answers 3

4

It's not clear from your question how you're storing the DCPs. It seems like you might be storing them in the database, in which case the code will indeed not be executed.

To execute code in DCPs you must either:

  • Use REL instead of JSP as your execution language
  • Publish the DCPs to the file system

Can you share your storage configuration?

UPDATE

Since they're in the database, the easiest thing to try is using REL. If the code you're executing is generated by Tridion (i.e. dynamic linking), then REL will work out of the box - all you have to do is change the CT output type to REL instead of JSP.

If there is additional custom code that needs to be executed, then you may consider creating your own REL tag (some examples here: http://jaimesantosalcon.blogspot.nl/2011/02/tridion-2011-ga-content-delivery.html) OR store the DCPs in the file system.

2

I played around with executing DCPs containing code that are stored in the Content Delivery Database.

The idea is to have custom class-loaders that interpret the 'string' coming from the DB as code and compile it dynamically in memory. Once you have the byte-code in memory, then you can simply instantiate an object from it (that's where the class-loader kicks in) and execute methods on it.

You can have a look at my blog:

1

Once a while I had almost similar issue with ComponentPresentationAssembler. I was not able to resolve component links in dynamic templates. Adding <%@ taglib uri="cd_tags" prefix="tridion" %> in dynamic templates resolved code execution. If you consume something out of tridion libraries, maybe you can check to specify invocation in your template same as I did.

Your Answer

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