268 The XML Files: Develo pment of XML/XSL Applications Using WebS phere Studio
Modifying the doPost me thod
Now we need to modify the doPost method. All we need is to invoke is the
doRegister method with HttpServletRequest. Once the doRegister succeeds, go
showpage to show results. If it fails, go back to the input form, which will be
reproduced by the doGet method. The doGet method r euses the XML Document
that is currently instantiated in the servlet ins tance, and the membership field has
been replaced with -1 message.
Example 11-4 CustomerXSLServlet doPost method
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{if( doRegister(request) == true){
showPage(resultStylesheet, response );
}else{
doGet(request, response);
}
}
If the membership already exists, Customer.xsl will be told as the m embership is
-1. To handle this to the meaning message, we used xsl:if tag.
Example 11-5 The xsl:if tag
<td>membership
<xsl:if test = "$membr = -1" >
*
</xsl:if>
:</td>
In this case, add * next to the membership. Or, use this ta g to show Membership
is already exist in the input field, or message area.