Chapter 9. Developing XM L Web services 191
򐂰javax.xml.transform.TranfrormerFactory
This is responsible for crating transformer object. TrasformerFactory is
abstract, and its new instance method is used to instantiate an instance of
Transformer class.
򐂰javax.xml.transform.Transformer
This instance is used to perform the actual transformation. It is not tread-safe,
so in a threaded servlet environment; this should be an instance variable. By
this restriction, you need to load XSLT on every request.
9.1.9 Test the passenger list application
In this section we test the passenger list application. You need to copy the
passengerList.xsl to the /WEB-INF/xsl folder, and copy the passengerList.xml to
the /WEB-INF folder in the Travel project. To test the application we have to start
a WebSphere test environment, and call the servlet from the browser. Since the
servlet does not need an input parameter, and implements doGet method, it can
be called using the URL directly.
Figure 9-10 passengerList result page
9.1.10 Compiling XSL
Since the Transformer is not a thread-safe, we need to instantiate the
Transformer on every request. Actually, in the doGet method, it is loading XSL
file from the stream every request. The XSLT Complier enables that it load in to
the Java vm as an object and reuse in the servlet instances. JAXP supplies the
templates interface to provide consistency. This interface has newTransformer