Creating a simple JSP-based test client

Together's deployment support will, at your option, generate a simple JSP-based client application to a location you specify in the EJB Deployment Expert. You can use this client to access a deployed EJB running on the server. This capability is currently available for WebLogic Server 5.1 and WebSphere 3.5.

When you select WebLogic Server 5.1 and check the Generate Simple JSP Client checkbox in the EJB Deployment Expert, a Java Server Pages (JSP) client for Enterprise JavaBeans will be generated during deployment processing. This client is the set of interrelated JSP and HTML files which can be viewed in any Internet browser. The purpose of the JSP client is to provide access to a remote EJB object through its open interfaces (i.e., "Remote" and "Home"). Generally, the "Home" interface is intended for control over remote object life cycles and the "Remote" interface is for calling remote object business methods. The simple generated JSP client is able to perform these operations and save you the necessity to write your own client program for testing purposes.

Some notes that are worth mentioning:

 Setting values on the JSP client page

When you check the JSP client generation option in the Deployment Expert, an additional page is included in the page sequence. You fill in a number of fields on this page with information to support JSP client generation.

JSP client fields in the EJB Deployment Expert (WebLogic version shown)

Fields for the Weblogic 5.1 version

The following fields are displayed in the Deployment Expert when Weblogic 5.1 is the selected server:

Fields for the WebSphere 3.5 version

The following fields are displayed in the Deployment Expert when WebSphere 3.5 is selected:

General considerations

Testing the deployed EJB using the JSP client

If you check the Show result after generation option, your browser opens and loads the html index page at the location you specified as the path for JSP browsing. Alternatively, you can use your browser to open the index.html file at that location.

You can click to link to the create() method to launch another JSP that creates and instance of the EJB object and enables you to access it's fields, as shown in the following figure.

Of course, the field content and results of the interaction will vary with the design and coding of the EJB... this interaction of an EJB running against an Access database is just an example of how you can use the JSP client to test a running EJB.

To carry on with the example, you can use the client to test the Finder method on an EJB by returning to the initial navigation page and running that method agains a known value, as shown below:

In this example, the result of the operation proves that the Bean and its business logic is functioning correctly: