Cincom

Using Registered Servlets


| Web Toolkit Tutorial Home | Table of Contents | Using Tag Libraries | J2EE Model Summary |
One small final touch remains on the J2EE model solution, that of registered servlets. The concept is very similar to what you will learn in the final lesson on logical names. For now, the changes will look purely cosmetic but in the final lession you will see the role they play in the J2EE model.

In this lesson, we will use a registered servlet for the logon page.

1. If VisualWorks is not already running, please start running it now, load the Web Toolkit parcel and start a Wave HTTP server. You should also file in the code from Toyz Inc J7.

2. This final phase of the application will be quite similar to the last phase but with 1 small difference. The logon page will use a servlet reference in the form tag. Perhaps the easiest place to start would be to copy all files used in the last phase (xxxxxxx7.zzz) to "version 8".
  • j2eeheader7.jsp --- j2eeheader8.jsp
  • j2eefooter7.inc --- j2eefooter8.inc
  • j2ee_navigation7.jsp --- j2ee_navigation8.jsp
  • logon7.ssp --- logon8.ssp
  • main7.ssp --- main8.ssp
  • j2ee_employeecourses7.ssp --- j2ee_employeecourses8.ssp
  • j2ee_allemployeecourses7.ssp --- j2ee_allemployeecourses8.ssp
  • j2ee_listbycourse7.ssp --- j2ee_listbycourse8.ssp
3. Of these files, some contain no changes at all except for changing references to files with a "7" in them to a "8". Those files are:
  • j2eeheader8.jsp
  • j2eefooter8.inc
  • j2ee_navigation8.jsp
  • logon8.ssp
  • main8.ssp
Edit these files and globally replace all sevens with eights.

4. The first change we will make is in the confgiuration file for the teach site. In the web directory, edit the teach-site.ini file. When finished, the file should look like the following:

[configuration]
# Note: configuration parameters are case sensitive.

directory = $(VISUALWORKS)/web/teach
environment = VisualWave
description = The TEACH System Site
home = logon8.ssp
registeredServlets = true

[logical-names]

# -----------------------------------
# Logical Names for the Teach site
# -----------------------------------

# ----- Registered Servlets

verify = servlet/ServletVerify8

The 2 new items in this configuration file are the lines:

registeredServlets = true
verify = servlet/ServletVerify8

These lines will inform VisualWave that logical names for servlets will be used and that any form tag that uses action="verify" will be equivalent to action="servlet/ServletVerify8".


5. Edit the file logon8.ssp and change the line:

<form action="servlet/ServletVerify8" method=post name=form8>

to

<form action="verify" method=post name=form8>

6. Edit the servlet ServletVerify8 and change the lines:

ifTrue: [ aResponse redirectTo: '/teach/main8.ssp'. ]
ifFalse: [ aResponse redirectTo: '/teach/logon8.ssp?msg=111'.].


to

ifTrue: [ aResponse redirectTo: 'main8.ssp'. ]
ifFalse: [ aResponse redirectTo: 'logon8.ssp?msg=111'.].


When you use registered servlets, the Web Toolkit can keep track of the site to which the servlet is registered. Therefore, the servlet does not need the /teach/ directory to specify the pages to which the redirects are going. This is one of the features/benefits of registering your servlets and allows your servlets to be reusable.

7. If you have already loaded the Web Toolkit parcel and have already started a WaveHTTPRequestBroker, (before you have edited the INI file and logon page), then perform the following steps:
  • From the Web Toolkit Configuration home page, click the Manage Server link
  • From the Server Management Page page, click the Reset Configuration link
  • From the Reset Configuration : COMPLETE page, click the OK link
  • On the Configuration Details page, you will see all configured sites. Select the teach site.
8. Test the logon page.

9. From the System Browser, <Operate-Click> the category of ToyzInc and select File Out As.... Enter ToyzInc_j8.st as the filename.

10. There is one final lesson - Using Logical Names - which is independent from the J2EE and ASP models and something unique to the Web Toolkit. If you wish to view this lesson, click here. Otherwise, click the link furthest right in the list below to view a summary of J2EE model concepts.

Congratulations! Phase 8 of the TEACH application is complete

You now should be able to:
Use registered servlets on forms

| Web Toolkit Tutorial Home | Table of Contents | Using Tag Libraries | J2EE Model Summary |