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.
Still too do: try to publish the DCP's to the filesystem, and test, but this is not preferred since the TCM ID's are retrieved from the Bro DB using the Query object. Prefer to have everything from the DB, not half DB and half FS because of some undocumented issue or wrongly implementation.