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
- 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
- Open the web.xml file.
- 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.)

This will add a listener element for the ContextListener
class.

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

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
- On the Servers right-click the target server and select Add
and Remove Projects.
- In the Add and Remove Projects dialog, click the Add button
to move the workshop-jsf-tutorial project into the Configured
projects column.
- Click Finish.
- In the Server View, right-click BEA
WebLogic Server and select Start.
- Open the internal web browser by selecting Window
> Show View > Other > General > Internal Web Browser.
- In the web browser address bar, enter the URL http://localhost:7001/pages/register.jsf.
- 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.
- Attempt to register with a User ID that is less
than 4 characters in length. Note that you will get an error response.
- 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