• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to grasp the basic design pattern for a store front

 
John Pritchard
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All-
2 months into some JSP/Servlet study. I've gotten through most of the JSP/Servlet syntax (well everything but custom tags) and trying to get a deeper understanding of how everything ties together. I've done quite a bit of experimentation code with one servlet/JSP passing data to another. What I want to tackle now is the basic construct for recurring dynamic data like a typical e-commerce storefront.
For example, if I have a page with a set of catalog categories, a link to a shopping basket, checkout, etc. Do you normally have this is a single JSP who forwards any user selection to a controller Servlet?
If I have want to have the user select a catalog category for example, how do I get the page to display everything the main page displays except thatthe center of teh page now has some catalog items? Are these includes?
If there is a Chapter in Professional JSP orthe Manning book - point me that way (getting through them as we speak)..
Thanks,
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Pritchard:
If there is a Chapter in Professional JSP orthe Manning book - point me that way (getting through them as we speak)..

If the Manning book you are referring to is Web Development with JavaServer Pages, checkout the chapter titled "An example JSP project" (Ch 9 1st ed, Ch 11 2nd ed). While this chapter doesn't specifically deal with an ecommerce type site, the general architecture for the example is applicable for a wide variety of purposes. This is a pretty good example of using MVC and once the concepts are grasped you will be able to apply this knowledge to MVC frameworks such as Struts once you get to that point.
Regarding some more specific questions you had:
JP: For example, if I have a page with a set of catalog categories, a link to a shopping basket, checkout, etc. Do you normally have this is a single JSP who forwards any user selection to a controller Servlet?
You might find it best to break up re-useable elements of your page design into separate jsps which you can then include as required (there are other templating methods as well but includes are usually sufficient). An example would be a menu which is re-used on multiple pages. Client requests should be directed to a controller.
JP: If I have want to have the user select a catalog category for example, how do I get the page to display everything the main page displays except thatthe center of teh page now has some catalog items? Are these includes?
Construct your page using includes for the re-useable elements. For your content, I would assume you would have an object in some scope that would contain a collection of catalog items. On your jsp iterate over the collection displaying each item as appropriate. Without using custom tags you might do something like this (let's assume CatalogItems has a getter which returns Item[]):

HTH
 
John Pritchard
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jason.
I also found a Core J2EE Pattern called Composite View which speaks to your note on seperate JSPs that are included in the view.
I appreciate the reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!