Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

onlyonce JavaServer Page tag

Updated on August 16, 2022

Use the onlyonce JSP tag to indicate that text within the body of the tag is to be included in the stream processing output only the first time that an onlyonce tag of that name is found.

This tag is primarily useful in complex HTML streams to prevent multiple definitions of JavaScript functions.

When to use

When entering HTML source code directly into the HTML tab of a control rule (or similar form), you can minimize the size of the resulting HTML document with the <pega:onlyonce > and <pega:static > tags. See Including only one copy of JavaScript code in More about control rules.


For example, this tag is named Alpha.

<!-- define scripts -->
<pega:onlyonce name="Alpha" >
The work item id is <pega:reference name=".pyID">
</pega:onlyonce >

During stream processing, if another onlyonce tag named Alpha appears, the body of the second (and later) tags are skipped over and not processed.

Complete syntax

In the syntax presentations below:

  • JSP delimiters <pega: and </pega: mark the start and end of the tag.
  • Replace any text in italics with your choice of value of that type.
<pega:onlyonce name="name" >
HTML, XML or JavaScript code to process only once
</pega:onlyonce >

The name attribute is required.

name Set the name attribute to an arbitrary non-blank text value. Case is significant. During stream processing, second and later appearances of an onlyonce tag with this name cause the body of the tag to be treated as a comment, contributing nothing to the stream results.

JavaServer Page Tags

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us