
HTML |
XSL Servlet
Customer
Result XSL
doPost
XMLToSQL
HTML |
normal case
XSLT
Processor
error case
XML Data
![]()
doGet
Customer XSL
Figure 11-7 The doPost method
Adding the error case
In the error case, we need to set back the data that was originally posted from the browser. Unless this functions, all user typed information has been cleared when the error occurred. To bring back the data to the browser, we need to modify the template. The original value attribute of the input tag is blank. To set back with the value that was previously typed (the XML data contains that data), use variable {$fname} in the value attribute. To set this variable, use xsl:variable tag and use the value of the current position. You need this modification to all fields.
Example 11-6 Customer.XSL firstname template
<xsl:template match="firstname"> <xsl:variable name="fname">
</xsl:variable>
<tr> <td>Firstname: </td>
<td><input name="firstname" type="text" size="20" maxlength="40" value="{$fname}"/></td>
</tr>