The sample HTML interface is an example of transforming the XML stream in HawkXml.xml into a format that can be used by an XML-aware application. This allows the XML data to be easily integrated with any application using XML with HTTP transport.
JSTL is an important specification of the Java Web platform that works with JSP version 1.2 and higher. This section explains how JSTL was used in the file
HAWK_HOME/webconsole/tomcat/webapps/http/jsp/alldomain.jsp to create the
Enterprise View HTML page. It illustrates the use of JSTL XML and Code tag libraries and expression language to retrieve XML content, parse it, and present in HTML.
You can refer to alldomain.jsp when reading this section. The JSPs are located in the
HAWK_HOME/webconsole/tomcat/webapps/http/jsp directory. All JSPs included with TIBCO Hawk HTTP Adapter follow the same programming pattern and are documented in the code.
The first step in using JSTL is importing the tag libraries. In the following code fragment from
alldomain.jsp, the Core, XML and Internationalization tag libraries are imported.
The following code fragment constructs the relative URL (Agents) to be invoked to retrieve the XML stream, and applies the stylesheet named
Nnames.xsl to resulting XML document.
In the following code fragment, the Core library tag is used to import XML content from the
Agents URL. The retrieved content is in raw XML text and is stored in a variable named
xml.
Raw XML content is not very useful and needs to be parsed. Parsing an XML document converts the raw XML into a format that can be handled with XSLT, XPATH, or other standard XML manipulation technologies.
The following code fragment parses the retrieved XML document and stores the result in a variable named
AgentDom. It uses the tag named
parse from the XML tag library.
The following code fragment retrieves the total number of TIBCO Hawk agents in all configured Hawk domains. It uses the XML tag
x:out and the XPATH function
count. You can use XPATH to select any nodes desired.
Following code iterates through all Agent nodes using the XML tag x:forEach. It also uses the XML tag
x:out to retrieve content for the selected nodes and store it in variables.
All retrieved information is stored in a HashMap named DomainMap, and later shown in tabular format. HashMap stores the domain name as a key and the highest alert state within the domain as a value.