I have been following with interest over the last few months the various
threads on web app architecture.  I am currently working on a small
servlet/JSP system and using a version of the single controlling servlet
model that has been discussed quite a bit.  I have an implementation
question.

I like the idea proposed by some people that the configuration of the web
actions be stored in a HashTable, which is loaded on application a startup
from a properties file or a database.  This allows the developer to avoid
hard-coding the following relationships:

1) The web "action" requested in the HTTP request, eg. URI
/controller/getClient
2) The class that the controlling servlet uses to processes the web action,
eg.  Barrack.JspBeans.ClientGetter.
3) The JSP page the bean or servlet then forwards to, to display the
required output, eg. URI /display/showClient.jsp

It seems common to implement the Command pattern in the processing class (#2
above), so the controlling servlet can simply call a "doAction(request,
response)" method on the class, without knowing anything about it.  All
makes sense so far...

So, finally, on to my question.

What if you would prefer to be able to configure both the class and a
specific method name that each web action maps to?  Is there and easy way
call a dynamically named method on a dynamically named class?  I guess this
is more of a generic Java question now, sorry.  I suspect that there are
things in the Reflection API that allow this, this is where I am heading
next.

The reason for this is that otherwise I have to create a separate class for
each action.  I would really prefer to group some of these action processing
methods together into a single class.  This is both to keep things tidy (?)
and to to store some state information in that bean from one method call to
the next (the class would be stored in the session).

This is for things like implementing a multi-page workflow where the bean
could then check it's internal state to ensure the pages are being completed
in the correct order, or what the previous page should be if the user want
to go "back".  It also seems a little closer to my limited understanding of
EJB Session Beans, which I believe implement the various actions that can be
performed as separate methods (??).

I'm interested in any opinions people have on (a) how to implement this and
(b) if they don't think it's a good idea, why.

Regards

Drew Cox
Barrack Consulting

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