The HTTP Post method of the servlet references the CustomerXML class, as shown in Example 10-4. It sets all the attribute values, after extracting them from the request. After all values are set in the customer bean present in CustomerXML, showPage is invoked.

Example 10-4 Source code for the servlet doPost method

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

{

CustomerXML xml = getCustomerXML(); xml.setMembership(new java.lang.Long(

request.getParameter("membership"))); xml.setFirstname(new java.lang.String(

request.getParameter("firstName"))); xml.setLastname(new java.lang.String(

request.getParameter("lastName"))); xml.setEmail(new java.lang.String(

request.getParameter("email"))); showPage(resultStylesheet, response);

}

XSL Files: By expanding the folder /Web Content/WEB-INF/xsl, under the Registration project, you will find two XSL files. The Cutstomer.xsl file represents the xsl for the input customer data, while the CustomerResult.xsl file represents the xsl for the data resulting from the registration process:

￿Customer.xsl is the style sheet for the customer registration form. Note the following:

The stylesheet code in Example 10-5 represents the style and the structure of the registration form. It is clear that it is stylesheet for an HTML form.

Example 10-5 Part of customer stylesheet specifying the overall form structure

<xsl:template match="/"> <html>

<head>

<title>Customer Registration Form</title> <style type="text/css">

<![CDATA[ body

{

background-color: #f8f7cd;

}

h1

{

color: #0000ff;

Chapter 10. Development of XML-based Enterprise applications 233

Page 249
Image 249
IBM Version 5 manual Example 10-4 Source code for the servlet doPost method