You can check on-the-fly for null in your hash map, that way you don't need
to specify the names of all possible action classes in init():
> // check the requestURI > actionName mappings
> String actionName = (String) mapping.get(request.getRequestURI());
> Action action = (Action) actions.get(actionName);
> action.perform();
becomes:
=code example start=
// check the requestURI > actionName mappings
String actionName = (String) mapping.get(request.getRequestURI());
Action action = (Action) actions.get(actionName);
if (action == null) {
actionClassName = ...;
action = (Action) Class.forName(actionClassName).newInstance();
mapping.put(actionName, action);
}
action.perform();
=code example end=
Personally, I'm implementing it the first way, because all of my action
classes are specified in an initialization file, so it only makes sense to
create them at startup.
Sam
===========================================================================
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