WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.xml.xslt

This example demonstrates using XML and XSLT to separate content generation from presentation.

See:
          Description

Interface Summary
Content The methods in this interface are the public face of ContentBean.
ContentHome This interface is the home interface for ContentBean, which in WebLogic is implemented by the code-generated container class ContentBeanEOImpl.
 

Class Summary
ContentBean This stateless Session Bean generates XML content that is later displayed to various client types.
 

Package examples.xml.xslt Description

This example demonstrates using XML and XSLT to separate content generation from presentation. In this example, the JSP presentation.jsp handles requests from both HTML browser clients and WAP-enabled clients. For each request, presentation.jsp calls ContentBean to generate the response content, shown by the following XML document:

 
<content>
  <title>
    XSLT example
  </title>
  <description>
    This example demonstrates the use of XML and XSLT as a way to 
    separate content from presentation.
  </description>
  <html_note>
    ContentBean generates the content in the form of an XML document. 
    Presentation.jsp uses XSLT to transform the XML document to a format 
    that is appropriate for the client making the request. Since you are 
    currently viewing this page in an HTML browser, more information can 
    be displayed than if you were viewing this page in a client with a 
    smaller display such as a WAP-enabled mobile telephone. See the example 
    documentation for instructions on viewing this page using a WAP emulator. 
  </html_note>
  <wap_note>
    You are viewing this page from a WAP-enabled client.
  </wap_note>
</content>
presentation.jsp then transforms this XML document using WebLogic's built-in JSP tags and XSLT processor into a format that is appropriate for the client type (HTML or WML).

The example demonstrates how to:

Additional Resources for examples.xml.xslt
presentation.jsp The JSP that handles client requests and uses XSLT to transform XML data into HTML or WML as appropriate.
html.xsl The stylesheet used to transform the XML document received from ContentBean into HTML.
wml.xsl The stylesheet used to transform the XML document received from ContentBean into WML.

IMPORTANT: You must install the following software to run this example:

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

  1. Build the example
  2. Configure the server
  3. Run the example

Build the example

  1. Set up your development shell as described in Quick Start.
  2. 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\src\examples\xml\xslt directory, to build the example.

    The Java Ant command builds the example and copies the files to the following directories of the WebLogic Server:

    The WebLogic server automatically deploys the EJB as soon as the build command copies the EJB files to the correct directory. If the WebLogic server is not running, the EJB is deployed as soon as you start the WebLogic server.

    For additional information on using the build commands, see Building Enterprise JavaBean examples.

Configure the Server

  1. Create (if it does not already exist) the directory SAMPLES_HOME\server\stage\examples\examplesWebApp\WEB-INF\lib, where SAMPLES_HOME refers to the main WebLogic examples server directory.

  2. Open the file WL_HOME\server\ext\xmlx.zip and extract the file xmlx-tags.jar into the lib directory you created in the preceding step. WL_HOME refers to the main WebLogic Server installation directory.

  3. Ensure that the following MIME types are registered with the Examples Web Application. These MIME types are, by default, automatically registered when the examples server starts.

    File ExtensionMIME Type
    wmltext/vnd.wap.wml
    wmlcapplication/vnd.wap.wmlc
    wmlstext/vnd.wap.wmlscript
    wmlscapplication/vnd.wap.wmlscriptc
    wbmpimage/vnd.wap.wbmp

  4. Ensure that the following JSP parameters are registered with the Examples Web Application. These JSP parameters are, by default, automatically registered when the examples server starts.

    ParameterValue
    compile commandJAVA_HOME/bin/javac
    pageCheckSeconds1
    verbosetrue

Run the example

Refer to the Nokia documentation for details on starting and administering the WAP Server and for using the WAP tookit.
  1. Start the WebLogic Server.

  2. Access the JSP presentation.jsp from an HTML browser using the following URL:
    http://WebLogicURL:Port/examplesWebApp/presentation.jsp
    where:
    WebLogicURL
    Domain address of the WebLogic Server
    Port
    Port where the WebLogic Server is listening for connections

    You will see a description of this example formatted in HTML.

  3. Start the Nokia WAP Server.

    NOTE:You must specify the /bin directory of the JRE 1.2.2 in your PATH to start the Nokia WAP Server.

  4. Start and log in to the Nokia WAP Server Manager (username="admin", password=""). Ensure that the UDP bearer adapter has been started.

  5. Start the Nokia WAP toolkit.

  6. Verify that the Nokia WAP toolkit is configured to pass all communication through the WAP gateway. To do this, in the toolkit menu:

  7. From the Nokia Activ Server Manager's General menu, select Start Traffic

  8. From the Nokia WAP Toolkit's Browser menu, select Load location...

  9. In the Open Location dialog box, enter:
    http://WebLogicURL:Port/examplesWebApp/presentation.jsp
    where:
    WebLogicURL
    Domain address of the WebLogic Server
    Port
    Port where the WebLogic Server is listening for connections

    You will see a discription of this example formated in WML. Note that the description is much shorter in WML than it is in HTML.

There's more...

Read more about XML in Programming WebLogic XML.

Read more in Programming WebLogic Server for Wireless Services.

Read more about EJB in BEA WebLogic Server Enterprise Java Beans.


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.