Hi Damian,

I can't answer how Craig does it, but I use a very similar approach and
that's how I do it:
My controller servlet reads its configuration from an XML file that,
among other things, has a portion like this:

<SUFFIX VALUE="myapp" />
...
<OPERATION
        NAME = "ShowMenu"
        CLASSNAME = "mypackage.MyClass"
        PARAMETER_ERROR_PATH = "/App/ShowMenuParamError.html"
        OPERATION_ERROR_PATH = "/App/ShowMenuOpError.jsp"
        UI_PATH = "/App/smMenu.jsp"
        >
...

That means that an URL ".../ShowMenu.myapp" would cause an instance of
the Action class mypackage.MyClass to be created, its parameters set
from the request and then executed. If the operation answers parameters
are wrong, control is forwarded to /App/ShowMenuParamError.html, if
something fails during execution of the operation control is forwarded
to /App/ShowMenuOpError.jsp(With the exception set so this can be a JSP
error page) and if everything works control is forwarded to page
/App/smMenu.jsp. Clean, flexible, easily configurable... I love it!

There's more to it as I included also application wide events and
security but that's another story.
I hope this helps,
Dan
-------------------------------------------
Daniel Lopez Janariz ([EMAIL PROTECTED])
Web Services
Computer Center
Balearic Islands University
-------------------------------------------


Damian Fauth wrote:
>
> "Craig R. McClanahan" wrote:
> >
> > The general organization of request processing in my apps goes like this:
>
> [..]
>
> > What I normally do is use a single servlet per web application, and then map it to
> > a filename extension (I like ".go" because it implies motion).  Now, if I submit a
> > form to URL "/saveCustomer.go", my controller servlet is called.  It can parse
> > "saveCustomer" out of the request URI and use it as the key to a lookup table
> > containing the Java class of the corresponding implementation class (all
> > configured in initialization properties -- no hard coding).  The first time I call
> > a particular action procedure, I instantiate a new instance of that action class.
> > After that, I resuse the same one over again (which must be thread-safe, for
> > obvious reasons).
>
> Using this approach, how do you determine which page to display next?
> Using your example above, would you then use
> getRequestDispatcher("/saveCustomer.jsp").forward(request,response)?
>
> How do you handle business-logic type errors that require the user to
> correct their form input? Presumably these would be detected in your
> Action class - can put some sort of ErrorBean into the request and
> forward() back to the referring page?
>
> Damian

===========================================================================
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