In the MVC architecture, the controller is what decides which user request is to handled by which component (which servlet, in the case of Java EE). Then, is the logic used inside the servlet (calling business methods or EJBs, etc) which is used to create the data that should be given to the view, called the model ?
In some books, its written that the servlet passes the model to the JSPs. In this sense, model is the data that is passed to the JSP. What’s the correct meaning of ‘model’ in a typical Java EE architecture ?
The model can concern both the “business model” and the “data model”. The business model is also known as “business delegates”, “domain objects”, “service facades” or anything in this sense. In a well designed Java EE web application according the standards, it are the EJB classes which does not use JPA or any DB access logic directly but delegate further to other EJB classes which are pure DAO objects.
E.g.
Note that, since this is an EJB, the
ProductDAO#update()andOrderDAO#create()are done in a single transaction. So if creating the order throws an exception, the edited availability won’t be persisted as well.The “data model” are the
Product,UserandOrderin the above example, which are supposed to be JPA@Entityjavabeans. This is all what the servlet (the controller) and JSP (the view) knows about.