MVC frameworks provide limited functionality when compared to ZK, Echo and other Java Web frameworks.
In the previous Industry Insight in this series, I looked at ZK and Echo and began looking at component-based frameworks. In this, the third article, I will consider MVC frameworks.
These frameworks all work in essentially the same way, by implementing the popular Model, View and Controller pattern. The front-end typically uses JSP, so the separation between presentation and logic depends on a disciplined development approach. MVC frameworks tend to focus on binding to the front-end, performing validation, and resolving request views and controllers.
They also tend to rely heavily on configuration, with the controllers typically implemented as Pojos and the views being simple JSPs with custom tag libraries, although recently a trend has developed to use convention over configuration.
These frameworks provide limited functionality when compared to the frameworks looked at in the previous two sections; in fact some of the frameworks already discussed include a full MVC in addition to the rest of their functionality.Frameworks:
Spring MVC, Struts 2
* Uses a well-known approach.
* Plumbing code usually configured with XML or annotations, or more recently by coding by convention.
* Widely used in production systems.
* Does not provide elaborate component libraries.
* Requires much configuration.
* Limited functionality makes these frameworks the first step above plain JSPs and servlets.
When to use these frameworks:
* For fairly simple front-end requirements.
* If you have an existing system and want to add the binding and flow control functionality that MVC provides.
* If already using Spring throughout your system, using Spring MVC could be a natural choice.
This is possibly the most widely used MVC framework, largely due to the success of the Spring framework with which it comes bundled. Like Spring, this MVC is non-intrusive, with the configuration located in Spring context files. Alternatively, annotations can be used, and from 2.5 many coding convention-based configurations have been introduced.
If already using Spring throughout your system, using Spring MVC could be a natural choice.
Since this MVC is bundled with Spring, it can form part of a complete application similar to Seam but without requiring a J2EE container. In the tradition of Spring, it integrates with many different technologies including other MVCs (Struts), various view technologies, Spring Security, and any service layer that Spring can be integrated with.
* Customisable, powerful binding and validation.
* Customisable locale and theme resolution.
* Powerful configuration capabilities using Spring application contexts.
* Part of the Spring framework.
* Works best with JSP as the front-end.
* Provides a simple MVC and not much else.
* Requires a lot of configuration.
In the next, final Industry Insight, I will look at other frameworks and factors to consider when choosing a Java Web framework.
* Andre van der Schyff is a senior developer at DVT.
Our comments policy does not allow anonymous postings. Read the policy here