Advanced Customization > Info*Engine User’s Guide > Info*Engine Tasks > Authoring Info*Engine Tasks > Scriptlets
  
Scriptlets
A scriptlet is a standard JavaServer Page (JSP) element that is commonly used in Info*Engine standalone tasks and on Info*Engine JSP pages. It is a valid Java code fragment.
Standalone Task Use
The task compiler copies scriptlets directly to the Java source code that is passed to the Java compiler. This allows Java programming logic to be embedded within Info*Engine tasks in order to implement conditional execution (if/then/else), iteration (for/while), and nontrivial computation.
Tasks can include embedded Java scriptlets (<% … %>).
* 
The following applies to the use of scriptlets when you have configured a task to use guaranteed task execution (if you have set ENABLERECOVERY to TRUE on the page directive).
Be careful when positioning scriptlets in tasks used in an Info*Engine environment where the guaranteed task execution feature has been implemented. Intermixing scriptlets with action webjects or task tags can interfere with the code generation used for supporting guaranteed task execution. To avoid problems, do one or more of the following:
Place your scriptlet either before the first webject or task tag, or after the last.
Avoid surrounding action webjects or task tags with scriptlets. For example, do not include the webjects or task tags in the for or while loops or in if/then/else constructs.
Specify the resumable=true attribute in all of your action webjects and task tags to disable the guaranteed task execution feature for the action webjects and tasks.
The last option is recommended in the cases where tasks are processed immediately when Info*Engine encounters the code rather than those submitted to a queue for execution.
JSP Use
Scriptlets are executed when the JSP interpreter processes the page containing them. This means that nested scriptlets are executed at the point when they are read. However, Info*Engine custom tags are defined so that the execution of nested custom tags is deferred until the end tag of the outermost block is reached. Therefore, any nested scriptlet on a JSP page is executed outside of context of the custom tag block in which it is nested.
You should not nest scriptlets in any Info*Engine tag block on a JSP page. To provide sophisticated solutions using the Java programming logic available through nested scriptlets, do not embed the solution in a JSP page. Instead, create standalone tasks that then can be executed on the page through the use of the Info*Engine task tag.
Tag Syntax
<% scriptlet %>
Example
The following scriptlet builds a where clause for querying a relational database table:
<%
String column = request.getParameter ( “column” );
String query = request.getParameter ( “query” );
if ( column == null )
column = “AUTHOR”;
String query = request.getParameter ( “query” );
String whereClause = "SELECT * FROM BOOK WHERE upper(" + column +
") LIKE upper('%" + query + "%')";

%>
<ie:webject name="Do-SQL" type="OBJ">
<ie:param name="INSTANCE" data="jdbcAdapter"/>

<ie:param name="SQL" data="<%=whereClause%>"/>
<ie:param name="GROUP_OUT" data="books"/>
</ie:webject>