Getting Started Samples: Java Controls

This sample demonstrates a basic application that shows how a custom Java control and a database control are used to model a simplified sign on procedure. Instead of running this finished sample, you can create this application by running the tutorial Getting Started: Java Controls.

The sample application allows a user to enter his/her name, and returns a greeting based on the number of times the user has entered this name before. The application contains the following components:

Concepts Demonstrated by this Sample

Location of Sample Files

This sample is located at:

BEA_HOME\weblogic81\samples\platform\GettingStarted_Control_Sample\GettingStarted_Control_Sample.work

To Run the Sample

  1. Start WebLogic Server in the workshop domain.
  2. Open MyControlTestProject_Sample\hello\HelloTest.jws and click the Start button.
  3. If this is the first time you have ever run this application, click the createTable button to make the table the database control is going to interact with.
  4. Scroll down to the Service Response section, and notice that no exceptions are thrown.
  5. Click the Test Operations link.
  6. Enter your name in the String field and click the hello button.
  7. Scroll down to the Service Response section, and notice that the response is Hello, <your name>!

    In the preceding two steps the web service invoked the hello method on the custom control. The control called the getVisits method of the VisitDB database control to find out the number of previous visits. Because you were running this test for the first time, this method returned 0, your name was added to the database using the database contro'ls insertVisitor method, and the Hello control sent the appropriate response.
  8. Enter your name again, click the hello button, and notice that the response is Hello again, <your name>!

    In this step the Hello control again invoked the getVisits method of the VisitDB database control to find out the number of previous visits. This method returned 1, the database record was updated to reflect that this was your second visit, and the Hello control sent the appropriate response.
  9. Click the Test Operations link, enter your name again, click the hello button, and notice that the response is Hello <your name>! This is visit number 3.
  10. Repeat the test with a different name and observe the outcome.
  11. Return to WebLogic Workshop and press the Stop button to close the Test Browser.

Related Topics

Tutorial: Java Control