This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Separate classes for each features. Is it a MVC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "Separate classes for each features. Is it a MVC?" Watch "Separate classes for each features. Is it a MVC?" New topic

Separate classes for each features. Is it a MVC?

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622

I have created a login, register and query features. I am using Hibernate for persisting the data. But i have created Separate classes for each features, like,, RegisterServlet, RegisterDao, QueryServlet, QueryDao. But I have also created different package for Servlet classes, and Dao classes. Is that ok? I guess that's not a perfect MVC. What all problems can i face in future as per this style of coding?

Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
What you have is a layered architecture where you have decoupled your presentation layer with persistence layer. When you implement an MVC, you need to present your view using JSP, FreeMarker, Velocity etc as well. You servlet should act only as a controller and should not be responsible for preparing the view for your request. It should dispatch the request to a JSP or appropriate view template after getting data from a Model (in your case DAO layer).

As for package structure, you can segregate them either by layer or by functionality and layer.

Layerd Package Structure

com.xyx. persistence.dao.QueryDao

Segregating based on functionality and layer



Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
Thanks for your reply Piyush. Yes, servlets just acts as a controller and dispatches the request to appropriate JSP. i also have a bean package where i have classes like,, There is a jsp folder inside WEB_INF. It contains all the jsp files. Any other advices or suggestions.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 653

Kunal Lakhani wrote:There is a jsp folder inside WEB_INF.

Please note its WEB-INF, not WEB_INF..
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Separate classes for each features. Is it a MVC?
It's not a secret anymore!