6 Using JSF and JSTL
This chapter describes how to use JavaServer Faces (JSF) and JSP Standard Tag Library (JSTL) with WebLogic Server.
This chapter includes the following sections:
Using JSF and JSTL With Web Applications
As of WebLogic Server 12.1.1, JSF 2.x and JSTL 1.2 have been incorporated directly in the server's classpath. Your applications deployed to WebLogic Server can seamlessly make use of JSF 2.x and JSTL 1.2 without requiring you to deploy and reference separate shared libraries, as was the case in previous releases.
For backward compatibility, WebLogic Server provides JSF and JSTL libraries that can be deployed and referenced by applications. See Deploying JSF 1.2 and JSTL Libraries.
For information on referencing these shared libraries with your Web applications, see "Creating Shared Java EE Libraries and Optional Packages" in Developing Applications for Oracle WebLogic Server.
If your application includes JSF JARs that you want to reference instead of the WebLogic Server bundled JSF shared libraries, you can configure a filtering classloader in
.ear) as shown below:
<prefer-application-packages> <package-name>javax.faces.*</package-name> <package-name>com.sun.faces.*</package-name> <package-name>com.bea.faces.*</package-name> </prefer-application-packages> <prefer-application-resources> <resource-name>javax.faces.*</resource-name> <resource-name>com.sun.faces.*</resource-name> <resource-name>com.bea.faces.*</resource-name> <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name> <resource-name>META-INF/services/com.sun.faces.*</resource-name> </prefer-application-resources>
JavaServer Faces (JSF)
JavaServer Faces technology simplifies building user interfaces for JavaServer applications. Developers of various skill levels can quickly build Web applications by: assembling reusable UI components in a page; connecting these components to an application data source; and wiring client-generated events to server-side event handlers.
WebLogic Server supports the JSF 2.1 specification at
http://jcp.org/aboutJava/communityprocess/mrel/jsr314/index2.html. For more information about JSF technology, see the product overview at
If you selected to install the server examples, you will find these JSF code examples, "Incorporating AJAX in Web Applications," "Using Facelets and Templating," and "Creating Bookmarkable Web Applications," in the
\wl_server\examples\src\examples\javaee6\jsf directory of your WebLogic Server distribution, where
EXAMPLES_HOME represents the directory in which the WebLogic Server code examples are configured. For more information about the WebLogic Server code examples, see "Sample Applications and Code Examples" in Understanding Oracle WebLogic Server.
JavaServer Pages Standard Tag Libraries (JSTL)
The JavaServer Pages Standard Tag Library (JSTL) encapsulates as simple tags the core functionality common to many Web applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating existing custom tags with JSTL tags.
WebLogic Server supports the JSTL 1.2 specification at
http://jcp.org/en/jsr/detail?id=52. For more information about JSTL technology, see the product overview at
JSF Compatibility with Previous Releases
If you prefer using shared libraries, the following packages are available:
The JSF and JSTL libraries are bundled as WAR files and are located in the WL_HOME
/common/deployable-libraries directory. The JSF libraries include the JSTL JAR files for convenience, so that if an application references a JSF library, it automatically gets JSTL support as well.
jsf-2.0.war shared library is empty and is included for backward compatibility for applications that have previously referenced that shared library.
Separate JSF and JSTL JAR files and implementation JAR files are also provided in the WL_HOME
/server/lib/api.jar file. You can reference these JAR files for compilation purposes or when using other utilities while developing Web applications.
For backward compatibility, JSF 1.2 and JSTL 1.1 packages are bundled with WebLogic Server as shared libraries, though they are deprecated in this release. Existing Web applications that use JSF 1.2 and JSTL 1.1 functionality can run on WebLogic Server. Choose the appropriate JSF or JSTL library based on your Web application.
In this release, the
weblogic.xml file in
jsf-1.2.war configures a filtering classloader for your application's JSF classes and resources.
Deploying JSF 1.2 and JSTL Libraries
In this release of WebLogic Server, you can deploy JSF 2.x and JSTL 1.2 applications directly. For backward compatibility, use the following directions when deploying JSF 1.x and JSTL 1.1 applications.
When deploying JSF 1.2 applications, use the JSF and JSTL libraries which are provided as Web application libraries. You must deploy the libraries before deploying the Web application that is using JSF 1.2 or JSTL functionality. You can deploy the libraries using the Administration Console or the command-line
Here's an example of deploying a JSF 1.2 library using the
java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password weblogic -deploy -library d:/oracle_home/wlserver/common/deployable-libraries/jsf-1.2.war
This command deploys the JSF 1.2 library using the default
implementation-version defined by the
MANIFEST.MF in the library.
After a library is deployed, the
implementation-version of the library can be found in Administration Console. This information can also be found in the
MANIFEST.MF file of the library
For more information on deploying a Web module, see "Preparing Applications and Modules for Deployment" in Deploying Applications to Oracle WebLogic Server.
Referencing a JSF or JSTL Library
To reference a JSF or JSTL library, a standard Web application can define a
<library-ref> descriptor in the application's
weblogic.xml file. Here is an example:
<library-ref> <library-name>jsf</library-name> <specification-version>1.2</specification-version> <implementation-version>1.2</implementation-version> <exact-match>false</exact-match> </library-ref>
For more information on referencing a Web application library, see "Creating Shared Java EE Libraries and Optional Packages" in Developing Applications for Oracle WebLogic Server.