Support for JSF 1.x and JSTL 1.x Libraries Configuring Resources in a Web Application Configuring Resources

Configuring JSF and JSTL Libraries 6-3 Heres an example of deploying a JSF 2.0 library using the weblogic.Deployer command-line: java weblogic.Deployer -adminurl t3:localhost:7001 -user weblogic -password weblogic -deploy -library d:beahomewlserver_10.0commondeployable-librariesjsf-2.0.war This command deploys the JSF 2.0 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 Administration console. This information can also be found in the MANIFEST.MF file of the library WAR file. For more information on deploying a Web module, see Preparing Applications and Modules for Deployment in Deploying Applications to Oracle WebLogic Server.

6.3.1 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 applications weblogic.xml file. Here is an example: library-ref library-namejsflibrary-name specification-version2.0specification-version implementation-version2.0implementation-version exact-matchfalseexact-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.

6.4 Support for JSF 1.x and JSTL 1.x Libraries

JSF 1.x and JSTL 1.x packages are also bundled with WebLogic Server as shared libraries. Existing Web applications that use JSF 1.x and JSTL 1.x functionality can run on the WebLogic Server. You can choose the appropriate JSF or JSTL library based on your Web application. For more information on the supported JSF 1.x and JSTL 1.x libraries, see Using JSF and JSTL With Web Applications at http:download.oracle.comdocscdE13222_ 01wlsdocs92webappconfigurewebapp.html in the WebLogic Server 9.2 documentation and http:download-llnw.oracle.comdocscdE11035_ 01wls100webappconfigurejsfandjtsl.html in the WebLogic Server 10.0 documentation. 6-4 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server 7 Configuring Resources in a Web Application 7-1 7 Configuring Resources in a Web Application The following sections describe how to configure Web application resources. ■ Section 7.1, Configuring Resources in a Web Application ■ Section 7.2, Configuring Resources ■ Section 7.3, Referencing External EJBs ■ Section 7.4, More about the ejb-ref Elements ■ Section 7.5, Referencing Application-Scoped EJBs ■ Section 7.6, Serving Resources from the CLASSPATH with the ClasspathServlet ■ Section 7.7, Using CGI with WebLogic Server

7.1 Configuring Resources in a Web Application

The resources that you use in a Web application are generally deployed externally to the Web application. JDBC data sources can optionally be deployed within the scope of the Web application as part of an EAR file. To use external resources in the Web application, you resolve the JNDI resource name that the application uses with the global JNDI resource name using the web.xml and weblogic.xml deployment descriptors. The web.xml file is located in the WEB-INF directory of your Web application. See Section 7.2, Configuring Resources for more information. You can also deploy JDBC data sources as part of the Web application EAR file by configuring those resources in the weblogic-application.xml deployment descriptor. Resources deployed as part of the EAR file with scope defined as application are referred to as application-scoped resources. These resources remain private to the application, and application components can access the resource names by adding resource-ref as explained in Section 7.2, Configuring Resources .

7.2 Configuring Resources

When accessing resources such as a data source from a Web application through Java Naming and Directory Interface JNDI, you can map the JNDI name you look up in your code to the actual JNDI name as bound in the global JNDI tree. This mapping is made using both the web.xml and weblogic.xml deployment descriptors and allows you to change these resources without changing your application code. You provide a name that is used in your Java code, the name of the resource as bound in the JNDI tree, and the Java type of the resource, and you indicate whether security for the resource is handled programmatically by the servlet or from the credentials 7-2 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server associated with the HTTP request. You can also access JMS module resources, such as queues, topics, and connection factories. For more information see, Configuring JMS Application Modules for Deployment in Configuring and Managing JMS for Oracle WebLogic Server. To configure resources: 1. Enter the resource name in the deployment descriptor as you use it in your code, the Java type, and the security authorization type. 2. Map the resource name to the JNDI name. The following example illustrates how to use an external data source. It assumes that you have defined a data source called accountDataSource. For more information, see JDBC Data Sources in Oracle WebLogic Server Administration Console Help. Example 7–1 Using an External DataSource servlet code: javax.sql.DataSource ds = javax.sql.DataSource ctx.lookup myDataSource; web.xml entries: resource-ref . . . res-ref-namemyDataSourceres-ref-name res-typejavax.sql.DataSourceres-type res-authCONTAINERres-auth . . . resource-ref weblogic.xml entries: resource-description res-ref-namemyDataSourceres-ref-name jndi-nameaccountDataSourcejndi-name resource-description

7.3 Referencing External EJBs