I've been trying to find a "great" example of a Model 2 Architecture
implementation.  So far, I've not had much luck.  This article from
JavaWorld comes pretty close, but lacks some important implementation
details.  The article is:

http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc_p.html

What the article fails to describe is how to best architect a *real-world*
e-commerce application.  If you look at the EShop.jsp file in the example,
the author has hard-coded the catalog list, rather than pulling that
information from a database.  While it is easy enough to throw in a
<jrun:sql> tag, that would violate the Model 2 design.  And in a real-world
e-commerce application, the home page would most likely also contain
additional database content such as featured products, a product category
list, and maybe top-sellers.

The article goes on to say that Servlets should act as the controller, using
beans to model the data, then forward to JSP pages to display results (act
as views).  That makes good sense, but the example he presents uses the
servlet only to respond to events such as FORM posts and URL links.  The
home page is just a simple JSP page.  So, if we we're to update ESHop.jsp to
generate the content from a database, how would we do that?

- Use a bean to get the data from a database?  Maybe have a SiteBean that
returns a vector of ProductBeans (for featured products)?

- Call a servlet from within the JSP page?

Has anyone come across a good example of how to do this?  Or, does anyone
have any suggestions on how to modify the example?





Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to