• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Action Servlet or Front Controller

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a question about which pattern to use on an upcoming project. Currently, the project will use Servlets, JSP and JDBC. Eventually, we want upgrade it to EJB's in the future.
So besides, the question above, what would be the best way to model the system so that changing from JDBC calls to EJB's goes unnoticed? I hope that makes sense. Would the Data Access Object pattern work?
The first part of the project is to add a scheduling module. Eventually we will add more module like webmail, task manager, etc. This will all be behind an password based authentication system. So ActionServlets or Front Controller.
Any ideas, pointers or suggestions would be great !!
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While it's great to debate patterns in the abstract, when it comes to productivity, many times you have to pick a framework and accept what it wants to work with.
One case in point: Struts is gaining popularity right now because it provides a lot of pre-built functionality that is easily extensible, is fairly light-weight, and (unlike many systems) doesn't suck you into a potentially expensive all-or-nothing commitment.
One thing that has become apparent (I suppose you could call it a meta-pattern) is that the cleanest way to connecting a JSP to a DBMS is to provide some form of facade - whether it be a custom proxy for an EJB/wrapper for JDBC code or a Struts Form Bean. Once you've determined that, the selection of pattern for the business logic becomes more a matter of what works well with your own needs and style. At the moment, I'm enamoured with Struts, so I'll use that as an example base.
In Struts, you may find it convenient to mix the Struts model for light-weight services with dedicated servlets for the "heavy lifting" parts. The Form Bean facade is self-contained, so you don't even need to duplicate database logic - the standalone servlets can use the same data access components that the Struts code uses.
The downside to an architecture like Struts is that while the individual components are simple, you tend to end up with a LOT of these simple individual components, and they must all be coded EXACTLY right - both internally and relative to each other, or you'll die the death of a thousand paper-cuts as you seek out and repair each mini-bug in its turn.
Or do like I do and cheat - I developed an open-source RAD tool called the EJBWizard that provides a GUI "fill-in-the-form" approach to designing EJBs. It's an extensible template-driven system. The current production release not only generates the prototype code for an EJB, but also
prototype JSPs for accessing and editing the generated EJB. I'm about to release a new Beta set of templates that generates all the requisite Struts code, properties, and assorted config files as well.
If you're in the "proof-of-concept" stage of development, you might want to get a copy of the EJBWizard and prototype some code. It might save you a lot of time. It's at http://www.mousetech.com/EJBWizard.html
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
Thanks for the response. I agree with you that a Facade would probably be the best route. I actually was thinking of developing a Helper class that the Struts Action Forms would call, and have the Helper implement the db calls. Later, I could modify that helper to call on a session bean in a Facade which in turn calls the Entity Bean.
I did a lot of research over the weekend and found the above info in a New Riders book on Tag Libraries. It dedicates 3 chapters to it and talks about refactoring the application to take advantage of EJB's.
The Front Controller pattern sounds intresting, but we just don't have the time at this moment to develop a framework for it. I don't think there are any framework available that utilize this pattern.
Anyway, Struts it is. I really like and it will decrease our development time dramatically.
Thanks for your input Tim
[ March 11, 2002: Message edited by: rick salsa ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic