I am trying to replace web.xml with a servlet as a front controller. I first tried using a request dispatcher and found that I still needed everything delcared in web.xml, which I don't see the point of adding a controller if the user can just go around it using the web.xml declarations. I have seen another pattern a few times (following) but haven't seen definitions of "RequestHelper", "Command", or "ApplicationResources". Where do these come from?
The Command Pattern is one of my favorites for some reason. The interface for your commands requires a method execute(request,response). There could be any number of concrete commands that do different things in execute, maybe one per form or one per business function.
You can see your code sample getting a command object. We don't see how, but the helper gets us a command object that is appropriate for the inbound request. It might use a hidden field or parameter on the request to get a command from a map. We can imagine that every page has a hidden field called "cmd" and the login page has a value of "login", The helper gets us an instance of LoginCommand, and the LoginCommand authenticates the userid and password fields on the form. Finally the command returns the page we should go to next, which I'll assume is a JSP, and we dispatch off to that page.
This has replaced the web xml mapping of URLs to servlets with our own mapping of "cmd" values to commands.
I made something very much like this at work this year. I like the way it works very well. Struts and other frameworks use the same ideas, but you can make something simple in only a few lines.
Other questions: It looks like "application resource" is a thinly disguised anchor for global variables. That's a necessary evil some times.
The "page helper" is not doing much beyond finding the right command for you. If it really did nothing else, I'd call it a CommandFactory instead.
Does all of that sound fun?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi