The Best Java Web Framework

Java has been around for a while. Soon after its initial inception, Sun started to push the platform towards the web. Now many years later, there are dozens of web frameworks and every now and then the same question pops up: which Java web framework is best.

No framework is perfect, they all have their merits and they all have their breaking points. There is not a single web framework out there that will work for all requirements out there, still there could be found arguments why one framework is better than others and for what types of applications. So let’s have a look at most viable Java web frameworks:

Servlets and JSPs

Some developers say that JSP technology is seriously outdated, while others see it from a little other point of view. The fact of the matter is that Servlets and JSPs do nothing for you – you do everything including mapping request parameters to objects and validating them.

Even with a big variety of frameworks out there, there is still a place for Servlets & JSPs. Smaller web applications are still quickly and cleanly built using them and you don’t need any external dependencies either. The only side note is that you do it properly, which means using Servlets to invoke business logic, using JSPs to generate the view and having JSPs contain no Java code, only JSTL tags and if you want custom tags.

Pros: good for a few pages/functions to implement
Cons: outdated

Javaserver Faces

Some hate it, some love it. The main reason most people hate it is its steep learning curve and the fact that people use it for all the wrong purposes. Speaking of the right purpose, JSF is primarily aimed at being used to build web components for enterprise applications. It is excellent for creating complex user interfaces as the framework takes care of wiring UI components to backend classes with automated validation and transformations going on. Due to its stateful nature you even have an object representation of the web UI available to you server side.

JSF itself is only the base actually. It is designed to be extended, and many third parties do just that. On top of JSF you also have JBoss, Richfaces, Icefaces, Primefaces, Oracle ADF, Apache Tomahawk, JBoss Seam, Omnifaces, etc. They all share the fact that they extend core JSF with more functionality, which usually comes in the form of Ajax controlled “rich internet components”. Jboss Seam is unique in that list as it does not actually aim to extend, but “seamlessly wire together” many frameworks and technologies to the enterprise platform.

Pros: Good for medium to complex enteprise webapps where full control over the front end is not a requirement. If the application is built and designed around a solid backend, JSF 2.1 is your friend.
Cons: Not an easy material. JSF is hard, and there isn’t rich online documentation. If your application aims around a rich and dynamic web 2.0 front end, JSF is not your friend.

Spring framework

Spring framework is not quite a ‘web framework’, but it is unique. IT shares JBoss Seam’s aim in wiring together many different technologies, both frontend and backend. You can use it as an alternative to Java Enterprise Edition technology, but you are just as free to wire Spring and JEE technologies into the same application.

So what does Spring offer itself? A bunch! It has a bean autowiring system to replace (or extend) the dependency injection model as it exists in the JEE specification. It also has an incredibly strong security model. Additionally instead of manually constructing objects, you “inject” them from a Spring managed context. Next Spring has a strong emphasis on the Model View Controller pattern. Spring provides default controller types for example, but you can also implement your own. As for the model layer the framework can setup JDBC, Hibernate, JPA, etc. for you and it can even manage the sessions and transactions. And finally it offers a built in web front end framework with easy to use annotations. I guess there is much more to add to this.

Pros: Excellent for building and maintaining large enterprise applications that also target other legacy systems and technologies. Spring is so flexible you’ll have the least trouble adapting it to whatever you already have floating around. Also there is a huge community around Spring.
Cons: Clunky due to its hugeness. There is also a big amount of legacy that the framework has to drag around.

Struts 2

Struts 2 is actually quite a clean and neat framework. If all you want to do is create simple web applications, “web 2.0” or otherwise, then it isn’t a bad idea at all to consider Struts 2. But it has limitations. The security model is weak. In this world of web heightened security demands, the framework does nothing to assist you or to help you prevent doing it wrong.

Pros: Good for web applications that do not have high security demands but will be a mix of complex forms and dynamic frontend pages. Low learning curve.
Cons: Weak security


A Wicket application, although targeting the web, develops like a Swing application. You work with components instead of a “backend and a frontend”. The separation between the two layers is almost taken away by Wicket. Instead you think in events. A user presses a button, what is supposed to happen? Anything you would basically do with Javascript using other frameworks, in Wicket you write it all using Java code. That is because it all happens server side, but the framework makes it seem like it all happens client side.

Wicket is also friendly to the developer. It integrates nicely into IDEs and even has built in support for hot-deployment making it far easier to change and debug your applications. Also boring and cumbersome features like making your application multilingual is made incredibly easy.

Pros: Wicket can handle most webapp needs including those that are oriented on the back-end and those that are oriented on the front-end.
Cons: Weak documentation (including the books); the alternative API design.


GWT offers incredibly powerful browser user interface capabilities; using it you can create the coolest web front ends with relatively little work. Google creates most of its own online web services using GWT.
On top of GWT itself Google also provides you a wide range of tools, for example a rich set of plugins for Eclipse. This makes it a complete package that is completely carried by Google itself. This keeps it all tightly integrated and documented, which is a big plus for a web framework.

An added bonus of GWT is its Java to Javascript conversion capabilities. The HTML 5 madness has begun and people are now actually writing whole applications in Javascript. Through GWT you don’t actually have to write your stuff in Javascript itself; you can write Java code instead and still end up with HTML 5 components.

Pros: Good to create highly complex and feature rich web user interfaces
Cons: The framework is different from any other framework out there. When you want to use it you start from scratch, so it may make it hard to adopt it for a new project.

Play Framework

This framework is relatively young. It lays down the rules, brings the conventions and provides you the foundation to allow you to quickly and painlessly develop web applications, without boilerplate, dependency conflicts or layer upon layer of configuration.

This framework can utilize the benefits of the Scala language (but it is also built for the Java language). The same is true for Play 2.0 which is out right now, and more so. This is mostly because the framework is modeled almost entirely after Ruby on Rails 3 including the available tooling.

Pros: stripping away the boring part of Java web development; being completely stateless and Rest-enabled; providing perfect hot-deployment without need for JRebel or JPA entities; integrates with many popular and important web technologies; manages dependencies for you without needing to learn the complexities of Maven; consolidates web dev into a neat package; incredibly easy ORM model based on Hibernate and JPA 2.0, with an additional layer that takes away the cumbersomeness.
Cons: The programming model is quite counter-intuitive; navigation is based on throwing exceptions. deploying is a bit of a mess using Play as you don’t deploy classes, you deploy the source files. The (alternative) way you manage a Play project makes it difficult to integrate it in for example a JEE application in a way that is easy to maintain.

For sure there are many, many more frameworks to be discussed, but most of them serve the same purpose. Could you pass out your personal recommendation what frameworks is better to use and for what types of application?

Thanks a lot in advance for sharing your advice!

%d bloggers like this: