[opencms-dev] jsp fragments in pages

Hein van der Kallen hvanderkallen at xs4all.nl
Tue Aug 12 14:29:37 CEST 2025


Laurent 
The classic way to include the result of a jsp in a page  is with <cms:include>  
See https://documentation.opencms.org/opencms-documentation/template-development/jsp-development/opencms-taglib/index.html and
https://documentation.opencms.org/javadoc/tld/ 

Old examples can be found in old opencms 6.0 documentation see : https://www.nisnest.gr/opencms/opencms/alkacon-documentation/documentation_taglib/docu_tag_include.html

There are two types of templates : 
The modern container-page template , called via the template property 
The xml content will then be formatted using a formatter ( a jsp file + formatter-config). And will be included in a container-page. 
You can also include a function  ( a jsp file + function config) in a container-page. 

The classic jsp template, called via the template-elements property 
Or more precisely : the template-elements property points to a page template ( a jsp file) for the xml-content type.
The page template generates a complete page from the xml-content file. 
The page template (template-elements property) for the xml-content type is defined in the <resourcetypes>  element in opencms-modules.xml
For instance
         <resourcetypes>
                <type class="org.opencms.file.types.CmsResourceTypeXmlContent" name="lottery" id="102">
                    <properties>
                        <property>
                            <name>template-elements</name>
                            <value type="shared"><![CDATA[/system/modules/com.yoursite.lottery/templates/lottery.jsp]]></value>
                        </property>
                    </properties>
                    <param name="schema">/system/modules/ com.yoursite.lottery/schemas/lottery.xsd</param>
                </type>
            </resourcetypes>

The page template itself can include parts of a basic jsp template ( also a jsp file).

A typical example of using a basic template in a page template would be
<c:set var="baseTemplate" value = "/system/modules/yourmodule/templates/yourtemplate.jsp" />  


<cms:include page="${baseTemplate}" element="head" />.
....
<cms:include page="${baseTemplate}" element="foot" />
 

Kind regards
Hein van der Kallen


-----Oorspronkelijk bericht-----
Van: opencms-dev <opencms-dev-bounces at opencms.org> Namens laurent.druart via opencms-dev
Verzonden: maandag 11 augustus 2025 16:32
Aan: The OpenCms mailing list <opencms-dev at opencms.org>
CC: laurent.druart <laurent.druart at ldict.be>
Onderwerp: Re: [opencms-dev] jsp fragments in pages

Hello,

Some tips on this subject?

Thank you.

Kind regards,

Laurent

> Le 6 août 2025 à 16:11, laurent.druart via opencms-dev <opencms-dev at opencms.org> a écrit :
> 
> Hello,
> 
> Is there another way to include JSP code (bean calls) on certain website pages other than using "functions"?
> I want to be able to use the templates I define on the website.
> 
> Thank you,
> 
> Regards,
> 
> Laurent
> _______________________________________________
> 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 
> https://lists.opencms.org/mailman/listinfo/opencms-dev
> 
> 
> 

_______________________________________________
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 https://lists.opencms.org/mailman/listinfo/opencms-dev






More information about the opencms-dev mailing list