Java Reference
In-Depth Information
18.7
D ESIGNING A B UDGET P RO S ERVLET
When designing a servlet, there are many different patterns to follow. We can't
hope to cover all the approaches that can be used for effective servlet program-
ming. What we hope to do is show you our previous BudgetPro GUI applica-
tion rewritten as a servlet, so that you can see the mechanics of a working servlet
application. From this, you can become accustomed to the mechanics of a
servlet so that you'll feel comfortable with other approaches, too. All servlets
need to use these basic mechanisms.
Our BudgetPro GUI application was started from the command line, with
a name for the budget and a total dollar amount. We'll use a static HTML page
with a form for supplying that information. That will invoke our servlet. The
servlet will use HTML pages analogous to the windows we used in our
GUI—there will be a main screen that shows the current account listing its
subaccounts, and there will also be a screen for creating new subaccounts.
One nice feature of HTML-based Web applications is that you can use
hyperlinks as a way to both select something and take an action on it. We'll use
that feature in lieu of a View Subaccount button. Instead of selecting a subac-
count and then pressing View Subaccount , the user will only have to click on
the name of the subaccount. As a hyperlink, it will make the request to the
servlet to view that subaccount.
We will still use a button to send us to the screen for creating the subac-
counts. We could have used a hyperlink, but this makes the browser page look
a bit more like the GUI version.
18.7.1
When designing servlets, it's handy to use static HTML pages as a prototype
for the work to be done. You can mock up the various screens using HTML,
simulate interactions by using hyperlinks to move between the screens, and get
a feel for what the screens and interactions will look like.
Such a prototype also serves as a “runnable” specification. It can sometimes
be easier to show the action than to describe it with words. And if you take care
when you are building these static HTML pages, most of the HTML can be
reused directly in the final product. (This will be even more true when we get
to JSP.)
Prototype
Search WWH ::




Custom Search