|
Using Registered Servlets |
|
|
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".
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]
The 2 new items in this configuration file are the lines:
# 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 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:
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:
|