I've a DCP that renders a JSP statement <% out.println("Hello"); %>
. I'm trying to execute the JSP statement by using the CD API on a static JSP page. I've tried all possible scenarios - making the DCP a REL and publishing it to the broker and making it a JSP and publishing it to the file system, but I'm not able to have the JSP statement executed.
Here's what I've tried so far:
- Made the DCP a JSP and configured the
cd_storage_conf.xml
to publish DCPs to the file system. The DCP goes to the file system as a JSP and I used theComponentPresentationAssembler
to execute the JSP statement. All I see on the page is the JSP statement rendered as-is. The static JSP page looks like this:
JSPPage dcdPage = new JSPPage(pageContext, "tcm:17-28489-64");
ComponentPresentationAssembler cpAssembler = new ComponentPresentationAssembler(dcdPage);
out.println(cpAssembler.getContent(20154,1029));
- Made the DCP a REL and configured the
cd_storage_conf.xml
to publish DCPs to the broker database. The DCP goes to the broker and I used theComponentPresentationAssembler
to execute the JSP statement, but still no luck. The page has the JSP statement rendered as-is.
I've looked into TREX, but couldn't find anything that helps resolve this issue. There was something similar Java code in DCP not exectued, but that too doesn't seem to have a solution. Any help would be greatly appreciated.
Update 1:
Using the code above doesn't seem to call the JSPProcessor. I believe it just gets the file from the location and displays it. The log shows no errors in this case.
2016-12-05 21:41:06,796 DEBUG FSComponentPresentationDAO - Retrieving default data location for publication: 17 2016-12-05 21:41:06,796 DEBUG FSComponentPresentationDAO - Looking for location for component presentation type: JSP 2016-12-05 21:41:06,797 DEBUG FSComponentPresentationDAO - FSComponentPresentationDAO.getFile(): Location found: C:\test\WebContent\dcp 2016-12-05 21:41:06,799 DEBUG ComponentPresentationAssembler - ComponentPresentation.getContent(componentId=19894;templateId=1029) found: com.tridion.storage.mapper.componentpresentations.JSPComponentPresentationImpl@14f2b1ba
However, if I use tridion tags, the JSPProcessor is called and there's an error thrown. Nothing gets rendered on the page.
<tridion:ComponentPresentation templateURI="tcm:17-1029-32" pageURI="tcm:17-28489-64" componentURI="tcm:17-20154"></tridion:ComponentPresentation>
The log shows an error here.
2016-12-05 21:50:03,298 DEBUG ComponentPresentationAssembler - ComponentPresentation.getContent(...) running JSP ComponentPresentation 2016-12-05 21:50:03,298 DEBUG JSPProcessor - JSPProcessor.run(...) absolutePath of cp: C:\test\WebContent\dcp\dcp1029_19894.jsp 2016-12-05 21:50:03,298 DEBUG JSPProcessor - JSPProcessor.run(...) documentroot C:.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\test\ 2016-12-05 21:50:03,298 ERROR JSPProcessor - JSPProcessor.run(...) The JSP ComponentPresentation is not located in the documentroot of your website; C:.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\test;C:\test\WebContent\dcp\dcp1029_19894.jsp
My question now is why does the JSPProcessor looking in the web root? Shouldn't it be looking in the sub-directory that's defined in the cd_storage_conf.xml
?