Previous Next vertical dots separating previous/next from contents/index/pdf

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:


  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. Create Server Configurations

Before you can run this sample application, you must have a server installed.

  1. Click on the Servers tab.
  2. Right click on the Servers tab and choose New > Server.

  3. Choose the type of server that you have installed. (The screen shot below shows BEA WebLogic Server as an example.) Click Next.

  4. In the New Server dialog, in the Domain home dropdown list, select <BEA_HOME>\wlserver_10.0\samples\domains\workshop_10.1.
    Click Next.
  5. Select the project name in the left pane and click Add to move it to the right pane. Click Finish.
  6. The new server is displayed in the Servers view.

5.4. Run the application

  1. In the Server View, right-click BEA WebLogic Server and select Start.
  2. Open the internal web browser by selecting Window > Open View > General > Internal Web Browser.
  3. In the web browser address bar, enter the URL http://localhost:7001/pages/register.jsf.
  4. 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.
  5. Attempt ot register with a User ID that is less than 4 characters in length. Note that you will get an error response.
  6. 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.

 

Skip navigation bar   Back to Top