6 Using JSF and JSTL

Learn how to use Jakarta Server Faces (JSF) and Jakarta Standard Tag Library (JSTL) with WebLogic Server.

This chapter includes the following sections:

Using JSF and JSTL With Web Applications

Jakarta Server Faces (JSF) and Jakarta Standard Tag Library (JSTL) are an integral part of Jakarta EE and, as such, are incorporated directly into WebLogic Server. All Jakarta EE technologies are present on the WebLogic Server classpath. No additional configuration is required to use any of the Jakarta EE technologies in your applications. Applications deployed to WebLogic Server can seamlessly make use of JSF 4.1 and JSTL 3.0 without requiring you to deploy and reference separate shared libraries.

The Jakarta EE API JAR file is included in WL_HOME\wlserver\server\lib\jakarta.javaee-api-11.1.0.jar, where WL_HOME represents the top-level installation directory for WebLogic Server.

For information about referencing these shared libraries with your Web applications, see Creating Shared Jakarta EE Libraries and Optional Packages in Developing Applications for Oracle WebLogic Server.

Jakarta Server Faces (JSF)

JSF 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.

Facelets Views

Jakarta Faces applications normally define views with Facelets and use the .xhtml file extension. Facelets is the current view-definition technology for Jakarta Faces. It is distinct from JSP pages (.jsp) and JSP documents (.jspx). The Jakarta MVC chapter uses JSP because Jakarta MVC 3.0 requires a built-in JSP view engine; that requirement does not make Facelets the default view engine for Jakarta MVC.

WebLogic Server supports the JSF 4.1 specification at https://jakarta.ee/specifications/faces/4.1/.

WebLogic Server’s Jakarta Faces implementation supports capabilities including:
  • CDI integration, including the CDI-compatible @ManagedProperty.
  • WebSocket integration through <f:websocket>.
  • Ajax method invocation.
  • Class-level Bean Validation through <f:validateWholeBean>.
  • Java date and time support.
  • Component search expressions.

If you selected to install the server examples with your WebLogic Server installation, the sample application demonstrates the following key features of JSF:

  • Ajax method invocation using the new <h:commandScript> component
  • CDI converter
  • Iterable h:dataTable
  • CDI for evaluation of JSF-specific EL implicit Objects
  • CDI injection
  • New Java date and time
  • @ManagedProperty
  • Iterable ui:repeat
  • Class-level bean validation using f:validateWholeBean
  • CDI validator
  • WebSocket using f:websocket

The JSF examples are located in the ORACLE_HOME\wlserver\samples\server\examples\src\examples\javaee8\jsf directory, where ORACLE_HOME represents the directory in which you installed WebLogic Server.

For more information about the WebLogic Server code examples, see Sample Applications and Code Examples in Understanding Oracle WebLogic Server.

Jakarta Standard Tag Library (JSTL)

The Jakarta 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

  • SQL tags

JSTL also provides a framework for integrating existing custom tags with JSTL tags.

WebLogic Server supports the JSTL 3.0 specification at https://jakarta.ee/specifications/tags/3.0/.

JSF Backward Compatibility

A Faces 2.x application can require migration before deployment on the Jakarta EE 11 runtime. In particular, application classes and libraries that use javax.* APIs must be migrated to the corresponding jakarta.* APIs unless the application uses an explicitly supported WebLogic Server compatibility mechanism. Remove any application-bundled Faces implementation before testing against the server-provided Faces 4.1 implementation.

Note:

The jsf-4.1.war deployable library, included in WebLogic Server, is empty, as applications built for JSF 2.0 will continue to run unmodified using the built-in JSF 4.1 implementation of WebLogic Server 26.1.0.0.0.

WebLogic Server includes the empty jsf-4.1.war library to avoid any software that depends on its existence. You can leave references to the library unchanged without harm. However, Oracle recommends removing any references to this empty library, as these references add no functionality.

See the following sections:

Deploying JSF and JSTL Libraries

Note:

In this release of WebLogic Server, you can deploy JSF 2.3 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 WebLogic Remote Console or the command-line weblogic.Deployer utility.

Here's an example of deploying a JSF 1.2 library using the weblogic.Deployer command-line:

Note:

Do not place an administrative password directly on the command line. Use the supported WebLogic Server user configuration and key-file mechanism, or enter credentials through the approved deployment workflow.
  java weblogic.Deployer -adminurl t3://localhost:7001 
    -deploy -library
   d:/oracle_home/wlserver/common/deployable-libraries/jsf-1.2.war

This command deploys the JSF 1.2 library using the default library-name, specification-version and implementation-version defined by the MANIFEST.MF in the library.

After a library is deployed, the extension-name, specification-version and implementation-version of the library can be found in the Remote Console. This information can also be found in the MANIFEST.MF file of the library WAR file.

For more information about 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 Jakarta EE Libraries and Optional Packages in Developing Applications for Oracle WebLogic Server.