Craig, I find your Web Application Design Philosophy posts incredibly useful.
They've been a big influence :-).

I've been building an app using a design similar to what you outline here,
specifically the part about using the request URI to dispatch to a given page
"controller".

One issue that has caused me a lot of trouble, though, is that I often want to be
able to have buttons on the same form send the user to different pages. Of course, a
form can have only one target URL, so I am stuck there. Instead of using <input
type="submit"> tags for my buttons, I could use links to different URLs, but then my
servlet/controller would never see the values the user has entered into the form,
which is important, since I want these buttons to go to "sub-pages" -- similar to
sub-dialogs in a conventional applications -- whose contents and behavior will
depend on the values in the parent page.

I worked out a complex, hackish solution where, for each <input type="submit"> tag,
I add a hidden field that adds the name of this button to the list of submitButton
values, and another hidden field that maps the button names to the "real" URI to
use. Then I use a special value for the forms target attribute to tell my
dispatching servlet to loop over the list of submitButton names, and see if any of
them show up in the parameter list. If it does, I use the hidden field parameter to
get the real URI. Wheww!

Any suggestions for approaches that may be more straightforward and easier to
program?

Yours, JonTom

    JT Kittredge
    ITA Software
    Cambridge, Massachusetts

"Craig R. McClanahan" wrote:

> David's concerns are quite valid -- one of the implications of the architecture
> I propose is that the servlet containing the business logic (essentially the "C"
> in an MVC architecture) has to select processing logic (i.e. specific Java
> classes) and the subsequent presentation logic (i.e. the URL of the JSP page to
> be forwarded to), without hard coding the set of possible selections.  I'm going
> to briefly describe the approaches I use to deal with these issues, and a couple
> of alternative approaches that seem to make sense as well.  (By the way, the
> same issues apply in a JSP-Bean-EJB type architecture -- they are just factored
> differently).
>
> SELECTING THE PROCESSING LOGIC
>
> The proposed architecture has a servlet receiving the input from every form.  It
> can make a decision of where to go next based on the request URI that was
> received, the request parameters, and/or current state information from the
> user's session. [...]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to