}

catch (Exception ex)

{

PrintWriter pw = response.getWriter(); pw.println("<html><body><h2>Transformation Error</h2><pre>"); ex.printStackTrace(pw); pw.println("</pre></body></html>");

}

}

Modifying the doGet method

Regarding the above modification, doGet must be changed to set document.

Example 11-11 showPage method

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

try{

showPage(mainStylesheet, response, getCustomerXML().produceDOMDocument());

}catch(Exception e){ System.out.println(e);

}

}

Modifying the XSL file

Since our main HTML is a dynamic thing, we can modify the transformation file to add Query Button to the main form (Figure 11-9). Open Customer.xsl file and look for membership template (Example 11-12).

Example 11-12 Customer.XSL membership template

<xsl:template match="membership">

<xsl:variable name="num"> <xsl:value-of select="."/>

</xsl:variable>

<tr> <td>Membership: </td>

<td><input name="memberhsip" type="text" size="20" maxlength="40" value="{$num}"/>

<input type="submit" name="queryBtn" value="Query"/> </td>

</tr>

274 The XML Files: Development of XML/XSL Applications Using WebSphere Studio

Page 290
Image 290
IBM Version 5 Modifying the doGet method, Example 11-11 showPage method, Example 11-12 Customer.XSL membership template