Skip to main content
1 of 5
user avatar
user avatar

Java code in DCP not exectued

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 display 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]
user348