[opencms-dev] using cms:include from a jsp

Mario Jäger m.jaeger at alkacon.com
Mon Dec 20 15:28:43 CET 2010


Hi,

When an user requests the URI of a xml content resource in OpenCms, then 
the "template-elements" property is read from the requested resource. If 
it contains a path to a JSP, this JSP is called. The JSP reads the XML 
content from the requested resource and renders it’s output from it. 
This is not the behaviour for a xml content you include in a jsp with 
<cms:include>. For example, the "template-elements" property of the xml 
content is not used then. <cms:include> dynamically includes JSP 
elements. Usually, <cms:include> is used with a "file" (or "property") 
attribute to specify the resource providing the included jsp element: 
<cms:include file="..." element="..." />. The "Null Pointer Exception" 
(you wrote in your first mail of) you get, because you used the 
<cms:include> for the xml content without the "element" attribute (you 
should use the <cms:content...> tags, not the <cms:include> tag to 
access the XML content elements). It seems, that the xml content we 
speak of, only shall be a sub element in the page you want to render. 
Only, if I would know the content of your module and some more details 
to the target you want to reach, I could say, if it could be improved. 
But, you say, that generally it works...

-- 
Kind Regards,
Mario.

-------------------
Mario Jäger

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

Am 17.12.2010 15:58, schrieb eelboy at aol.com:
> Because I was trying to do it via a cms:include from another page....
> It works as expected if I go to my browser with
> http://host.com/opencms/opencms/my_structured_content.html.  My problem
> was that my_structured_content.html is designed to fit only in another
> page (never like the http url I just mentioned.)  Rather, by a user
> going to http://host.com/opencms/opencms/index.jsp I wanted my index.jsp
> to have a cms:include of my_structured_content.html.  And when I did
> this I wanted the templates-element of my_structured_content.html to be
> used.
>
> Does that make more sense?
>
> On 12/17/2010 4:43 AM, Mario Jäger wrote:
>> If I understand you right, then you have tried to render the xml content
>> using its jsp, which is configured in the "template-element" property.
>> But, that did not work. What were the reasons for that?
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list