5. Running the Application

In this step, we will create server configurations and deploy and run the JSF application.

5.1. Add Context Listener and update application configuration

Our application uses the DataStoreBean class which is available in application scope. You have been provided a Servlet Context Listener called ContextListener which registers an instance of DataStoreBean to ServletContext at application start up.

5.1.1. Import the ContextListener class

  1. Create a new package called listeners and copy the file ContextListener.java from the folder workshop-jsf-tutorial/web/Resources folder to the listeners package.

5.1.2. Add context listener to web.xml file

  1. Open the web.xml file.
  2. In the Web Application Deployment Descriptor Design Editor right-click the Listeners node and select New Listener. Choose the listener type ContextListener as shown below. (Type out "ContextListener" in the Select entries field.)


  3. This will add a listener element for the ContextListener class.

  4. Save the web.xml file and review the web application configuration elements.


  5. The servlet javax.faces.webapp.FacesServlet is configured to receive HTTP requests with URL-pattern .jsf

    The web.xml file includes tag library mappings to support JSP tag libraries.

5.2 Configure WebLogic Server

In this step you will add a WebLogic Server domain for use with Workshop. This server domain contains runtime libraries required by the application and the application will be deployed to this server.


5.3. Run the application

  1. On the Servers right-click the target server and select Add and Remove Projects.
  2. In the Add and Remove Projects dialog, click the Add button to move the workshop-jsf-tutorial project into the Configured projects column.
  3. Click Finish.
  4. In the Server View, right-click WebLogic Server and select Start.
  5. Open the internal web browser by selecting Window > Show View > Other > General > Internal Web Browser.
  6. In the web browser address bar, enter the URL http://localhost:7001/pages/register.jsf.
  7. In the User ID field enter "ricky". Leave the Password field blank. Note that if you try to submit the data without filling in the Password field, you will get an error response.
  8. Attempt to register with a User ID that is less than 4 characters in length. Note that you will get an error response.
  9. On successful registration, the user will be forwarded to the home.jsp page.

Click one of the following arrows to navigate through the tutorial:


Still need help? Post a question on the Workshop newsgroup