Package examples.xml.sax

This example demonstrates how to parse an XML document using a SAX parser obtained via JAXP.

See:

 

Class Summary

RequestHandler This class extends HandlerBase and is used to handle events created as an XML document is parsed by a SAX compliant parser.
 

Package examples.xml.sax Description

This example demonstrates how to parse an XML document using a SAX parser obtained via JAXP.

The example receives an XML file over HTTP from a client and uses the SAX API (via JAXP) to parse the document.

The example illustrates how to:

  • read an XML file and write it to an output stream.
  • validate and parse XML data using a SAX parser.
  • pass XML data between a client and a JSP via an HTTP POST.

  Additional Resources for examples.xml.sax

Sax.jsp The JSP that receives the XML data from the Java Client, parses it, and sends an acknowledgement back to the Client over HTTP.
purchaseorder.xml The XML file that is passed between the Java Client and the JSP over HTTP.

The following sections describe how to build and run the example.

  1. Build the example
  2. Run the example

Build the example

  1. Set up your development shell as described in Quick Start.

  2. Change to the example directory:
     prompt> cd $SAMPLES_HOME\server\examples\src\examples\xml\sax
    where $SAMPLES_HOME refers to the main WebLogic Server samples directory, such as c:\beahome\weblogic81\samples.

  3. Compile the example by executing the Java ant command:
      prompt> ant 
    The Java ant command uses the build.xml file, located in the $SAMPLES_HOME\server\examples\src\examples\xml\sax directory, to build the example, where $SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\beahome\weblogic81\samples. The Java Ant command performs the following steps:

    1. Compiles the Client.
    2. Compiles the RequestHandler class into the WEB-INF\classes directory of the examples Web application.
    3. Copies the Sax.jsp file into the examples Web application directory.

Run the Example

  1. Start the WebLogic Server in a new command shell.

  2. In your development shell, run the Client with the following command:
      prompt> ant run  

  Read more about: