# <netui-data:getData> Tag

This tag evaluates an expression and places the result in the javax.servlet.jsp.PageContext object, where the data is available to JSP scriptlets.

## Syntax

<netui-data:getData
resultId="string_resultId"
value="expression_value" />

## Description

This tag evaluates an expression and places the result in the javax.servlet.jsp.PageContext object, where the data is available to JSP scriptlets. This tag can be used to extract data from forms, Controller files, and any data binding context and make it available to scriptlets.

The following <netui-data:getData> tag extracts data from the Controller file and places it in the `myData` field of the PageContext object:

        <netui-data:getData resultId="myData" value="{pageFlow.myData}"/>

The following scriptlet extracts the data from the `PageContext` object and writes it to the rendered HTML:

        <%= pageContext.getAttribute("myData") %>

## Attributes

resultId | Specifies the property of the PageContext object where the data will be stored.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | No
value | The data binding expression to evaluate. The result will be stored in the PageContext object as specified in the `resultId` attribute.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | Yes

## Sample

In this first sample, the <netui-data:getData> tag loads data into the `PageContext` object. You can subsequently access the data through the PageContext's `getAttribute(String)` method.

        <netui:form action="lastNameAction" focus="lastname">
             ...
             <netui-data:getData resultId="first" value="{actionForm.firstname}"/>
             ...
             <%
                 String firstName = (String) pageContext.getAttribute("first");
                 System.out.println("First Name = " + firstName);
                 ...
             %>
             ...
         </netui:form>

This next sample shows how to use <netui-data:getData> and the `PageContext` inside of other containers, in this case a <netui-data:repeater> tag. The <netui-data:getData> below extracts each element as the <netui-data:repeater> iterates over the data set and writes it to the Java console:

        <netui-data:repeater dataSource="{pageFlow.strArr}">
             ...
             <netui-data:repeaterItem>
                 <netui:label value="{container.item}" />
                 <netui-data:getData resultId="item" value="{container.item}"/>
                 <%
                     String currentItem = (String) pageContext.getAttribute("item");
                     System.out.println(currentItem);
                     ...
                 %>
              </netui-data:repeaterItem>
              ...
          </netui-data:repeater>

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_databinding/getData/

## Related Topics

<netui-data:getData> Tag Sample

Using Data Binding in Page Flows (PageContext section)

javax.servlet.jsp.PageContext