Hi Craig,

Thanks for the reply. I will do the same as you..put my comments in below
yours.

>Sounds like you are going the right direction for the right reasons.

Most definitely.

>In my apps, I chose to link directly to the next JSP page when there was
>no business logic that needed to be executed -- for example, navigation
>links and the like.  Otherwise, I always filter through the controller
>servlet.

Sounds exactly like what I was aiming for. Just want to make sure you mean
that when you filter through the controller servlet, its always a
form..right? Form data I believe would be the only reason to go through the
servlet, otherwise its a link to another page that doesn't require any
business logic.

>The approach I use is to divide the business logic parts into separate
>classes that implement an Action interface, rather than being methods in a
>paticular servlet.  The name of the class to use for each selection is
>stored in a Hashtable (loaded in the init() method).  Fundamentally, my
>controller's doGet() servlet looks like this:
>
>* Extract the selection code as described above.
>
>* Use that to do a hashtable lookup, and retrieve
>  the class name of the action class to use.
>
>* Use the class name to look up an action class
>  instance of this class in a second hashtable (the
>  first time a particular action class is used, I
>  create a new instance and store it here, under the
>  class name).
>
>* Call the perform() method of this action class
>  (the method is defined in the Action inteface).
>
>This avoids having all the logic in a single class, and having to use a
>big switch or if/else chain to call the right method.

Sounds good..but a bit more work than I think is necessary for this. I take
it your using reflection for this? Its an interesting approach. Do you use a
property file to store the class names for actions? How is your Controller
servlet actually implemented to get the "action" from a form? Are you using
the hidden command field with the name of the class to call or something? I
honestly thinnk a hidden field is easier to work with than extra path info.
Probably nothing much different.

>That's what I do, although not all my apps need EJBs.  Basically, the
>action method in the controller servlet uses session attributes, or
>request attributes (depending on how long I need the data) to pass results
>on to "view" JSP pages.

But, the "work" is done in the EJB, right? Or do you actually do logic in
you Action class that is called by the Controller servlet? If you do, does
that mean your Action classes can become EJB when you move to it? I would
think your action class(es) would not do the logic..it would merely connect
to an EJB to do the logic.

>Yep squared.
>
>You might also look at using JSP "custom tags" to create complex HTML
>representations of your business objects.

Well, we are using JSP 1.0, not 1.1, so I cant use custom tags at this
point.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to