Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

MVC Pattern for Shopping Cart Application

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application of Shopping cart like in Profession JSP of wrox and I want to convert it by applying MVC Design Pattern to get it through.
Would anybody of you all like to advise me the measures and design enable me to apply MVC for my application.

Thanking you in advance.
Kind regards
Rashid Ali
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I asked a similar question a week or two ago in the servlets forum. You can find that discussion here. That discussion was based mostly on the servlet (controller) and model classes, but you might find it quite beneficial - I did.
Hopefully, that will help get you started. If you have an initial design or some pressing questions before you get started, let me know and I'll help as much as I can. Otherwise, if you just need to know more about MVC, try here. If that's not enough, I'm sure Google would be useful.
I hope that helps,
Corey
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ali,
If it is possible to describe more abt your project, at least the architecture.
With MVC u can have 2 approaches..
1. jsp(view), servlet(as controller) and javabean(as model).pass the request from the jsp to the servlet, let the servlet do the buisness logic processing and all the db related stuf including the db connection can be put in a bean and that can be invoked by the servlet, after processing the servlet picks up a jsp page for display.
2. A full jsp-centric architecture where
jsp(view)jsp(controller)and javabean(model)
3. A full servlet-centric architecture where
a servlet(view) servlet(controller) and java classes/java bean as model.
4. An EJB centric architecture
a) jsp(view)/servlet(controller and client to the EJB(Entity Bean..models data)
b) jsp as client to the EntityBean
U can make a decision based on the overall nature,no of users, data involved, transactions involved and take up any of the above approaches.
Rishi Singh
SCJP,SCWCD
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rishi Singh:
1. jsp(view), servlet(as controller) and javabean(as model).pass the request from the jsp to the servlet, let the servlet do the buisness logic processing and all the db related stuf including the db connection can be put in a bean and that can be invoked by the servlet, after processing the servlet picks up a jsp page for display.


In general, when using such an architecture, I think you'd want to keep your business logic out of the servlet. If it's going to be the controller, that's all it should do. The business logic is better left in the model section.
When it comes to things like database access (or any external system access, for that matter), classes for those should be abstracted to another layer for maintainability purposes.
If you keep throwing things in the servlet, such as business logic, you'll soon find that it becomes difficult to extend the system through that servlet. I believe this will lead you to the "Magic servlet" antipattern that has been discussed here over the last couple days.
Corey
 
Everybody's invited. Except this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!