Hi,
I am reading the contents of an xml file in my
jsp through the jstl xml tags. How do i retrieve the data and set it into another variable, so that i can use it to either output on the browser or set in the html input tag.
I tried the below, but it does not work. The xml document is in the memory in request scope (xmlDoc)
<x:choose>
<x:when select="$xmlDoc/document/validation/flag[text()='N']">
<x:set var="name" select="$xmlDoc/document/names/firstName"/>
</x:when>
<x:otherwise>
<x:set var="name" select="$xmlDoc/document/names/lastName"/>
</x:otherwise>
</x:choose>
<b><c:out value="${name}"/></b>
<input type="hidden" name="name-text" value="${name}"/>
Assume that the condition is not satisfied and it goes into the 'otherwise' loop. I verified this by putting a c: out in both the 'when' and 'otherwise' clause and 'otherwise' got executed. c:out for name displays question: null
The same value gets displayed for the value of the input tag.
If I change the select to $xmlDoc/document/names/firstName/text(), then c:out displays #text: ABC (i.e the value present for the element node question.
Could someone please let me know what is wrong and how do i correct it ?
I do not want to use x:out tag and input html tag in both 'when' and 'otherwise' loop.
Thanks.