I have recently ran
across this interesting, web app. It is a quite MVC-ish with a
Controller servlet and Model beans, but too much logic in the JSPs to be
strictly Views (no taglibs).
This app features a page with a hierarchical,
walking menu, somewhat like a "DHTML Labs" HierMenu.
However, each step through this menu hiearchy
requires (??) an interaction with the web server. [I leave open the
possibility that the "walking" requests to the server might be overkill in
this case.]
Fetching each successive level of the
walking menu from the server is handled in a complex JavaScript
in this app. This JS sends a request, a POST, to the
controlller, giving the level in the hierarchy and the OPTION picked
in the last traversed SELECT list. The browser gets back a
Status Code=204, NO CONTENT. The screen is not updated, except as
noted below. The document model (including JavaScript) is not
replaced. The JS now examines the Cookies where it finds the encoded
options for the next select list. It then fills in that select list with
the newly received options. Very smooth screen changes. The MVC
ideal.
(So OK, the graphics aren't so great. It
not really a HierMenu. It doesn't really "walk" The "menu" is
fully extended to begin with. The "unwalked" lists on the right are
empty. But its the same idea. And it could scale up nicely beyond
what DHTML could do with wimpey static hierarchies.)
Is this legal? I think so. It does seem
to be what 204 (NO CONTENT) is intended to be used for. So that's
kosher.
Cookies get a lot of bad press. But, cookies
(or complex URL encoding) are the fall-back when session beans are
not going to be used. Many JSP developers will shun
session beans because the app might get deployed on clustered servers
(reverse proxied). Each POST might then be dispatched to a different
JVM. Session beans were not shared correctly among clustered JVMs until
Servlet 2.3. (Correct me if I am wrong.) Nobody is there yet
in the commercial offerings.
Is there any one of us working on a taglib
for Sruts with cookie hacks like this? Or, am I going to
get a well-deserved flaming for even suggesting the possiblity.
Dan Connelly
(Not the famous guy at W3C).