Advanced Customization > Info*Engine User’s Guide > Info*Engine Tasks > Nesting Tasks
  
Nesting Tasks
Although any number of webjects can be included within a task, there are times when repetitive tasks are performed. Candidates for task nesting include any general task that might be used under multiple conditions. By using dynamic substitution (which is described in Dynamic Parameter Value Substitution), you can easily construct tasks that can be used multiple times.
You can nest tasks by specifying the Info*Engine custom task tag within a task.
task Tag Rules for Nesting Tasks
When working with the Info*Engine task tag, the following rules apply:
You can nest any number of tasks within another task, and nested tasks can contain other nested tasks.
The task file being referenced can also contain any of the task webjects and any of the custom tags that are available to tasks.
You should always provide exception processing within your task to catch errors when nested tasks fail.
The syntax and complete description of the task tag is described in task Tag.
Simple Nested Task Example
The following task includes a task tag that executes another task named QueryTask.xml:
<%@page language="java" session="false"%>

<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
           prefix="ie" %>

<process name="Embedded Task Example with exception handle">

<ie:unit>

  <ie:task uri="infoengine/examples/QueryTask.xml"/>

  <!-- If task fails, print message to stderr and
       throw exception-->

 <ie:failure>
    <%
    System.err.println("FAILURE when calling QueryTask.xml");
    %>
    <ie:webject name="ThrowException" type="MGT"/>
  </ie:failure>

</ie:unit>
</process>
Assume the QueryTask.xml file contains the following:
<%@page language="java" session="false"%>

<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
           prefix="ie" %>

<ie:webject name="Query-Objects" type="OBJ">
  <ie:param name="INSTANCE"  data="com.myHost.Adapter"/>
  <ie:param name="CLASS"     data="salesemp"/>
  <ie:param name="WHERE"     data="()"/>
  <ie:param name="GROUP_OUT" data="sales"/>
</ie:webject>
For additional examples of webjects that can be used in nested tasks, see Dynamic Parameter Value Substitution.