DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • How Stalactite ORM Implements Its Fluent DSL
  • Spring Beans With Auto-Generated Implementations: How-To
  • Why Java Is so Young After 25 Years: An Architect’s Point of View

Trending

  • A Modern Stack for Building Scalable Systems
  • Artificial Intelligence, Real Consequences: Balancing Good vs Evil AI [Infographic]
  • Comparing SaaS vs. PaaS for Kafka and Flink Data Streaming
  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  1. DZone
  2. Coding
  3. Frameworks
  4. Most Popular Java Web Frameworks

Most Popular Java Web Frameworks

As Java has evolved, different frameworks have spun up to simplify development for different use cases. Check out the most popular Java web frameworks below.

By 
Vince Power user avatar
Vince Power
·
Jason Skowronski user avatar
Jason Skowronski
·
Feb. 27, 18 · Opinion
Likes (16)
Comment
Save
Tweet
Share
72.5K Views

Join the DZone community and get the full member experience.

Join For Free

As Java has evolved over the years, multiple attempts have been made to simplify development for various use cases. From official standards like Java Enterprise Edition, to community-driven frameworks, Java is continuing to prove itself to be adaptable and viable.

Our top list is based on usage from Hotframework.com's Java ranking and several other sources including blog posts and GitHub download numbers.

The top three are:

  • Spring
  • JSF
  • GWT

Other notable Java Web Frameworks:

  • Play!
  • Struts
  • Vaadin
  • Grails

Java Frameworks that are popular but not for the Web (We don’t want to forget them):

  • Hibernate (Data-focused)
  • Maven (Build-focused)
  • Apache Ant with Ivy (Build-focused)

Spring

Project Site: https://spring.io/

Primary Sponsor: Pivotal Software

Spring is more than just a web framework. It is a complete programming model that is built on and with Java, starting with Spring Boot, which is a way to get a spring application up and running with minimal configuration and no application server required. At the other end of the spectrum is Spring Cloud, which is a combination of components that allows developers to build resilient and reliable cloud-native applications that leverage the latest distributed patterns like a microservices architecture — two examples include application security and batch processing.

There are many use cases for Spring, and with the introduction of Spring Boot, it is a great solution for companies that are moving towards containers as it greatly simplifies the components required to support the running application.

Getting started with Spring is as simple as going to Spring Initializr and selecting the build framework you desire and any and all the Spring projects you want included in the initial application. It will create the Maven or Gradle configuration and all the basic spring configuration required to start.

Creating a simple web application starting with Initializr (Figure 1):

Spring Initializr

… which will create a Zip file with the following files in it:

./mvnw.cmd
./pom.xml
./.gitignore
./.mvn/wrapper/maven-wrapper.properties
./.mvn/wrapper/maven-wrapper.jar
./mvnw
./src/test/java/com/example/demo/DemoApplicationTests.java
./src/main/resources/application.properties
./src/main/java/com/example/demo/DemoApplication.java

You need a Controller — src/main/java/com/example/demo/DemoController.java:

package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class DemoController {

    @RequestMapping("/hello")
    public String hello() {
        return "hello";
    }

}

And a template file — src/main/resources/templates/hello.html

<!DOCTYPE HTML>
<html>
<head>
    <title>Hello World</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <p>Hello World</p>
</body>
</html>

JSF (Java Server Faces)

Project Site: http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html

Primary Sponsor: Oracle (soon to be a separate foundation)

JSF is a specification for displaying web user interfaces that is defined as part of the Java Platform, Enterprise Edition (JEE). JSF 1 was released in 2004, incorporated into JEE 5 and uses Java Server Pages (.jsp) as its templates. JSF 2 was released in 2009 as part of JEE 6, and leverages Facelets for templating and supports AJAX calls with a browser to allow modern web application lifecycles. JSF is component-based, allowing it to be expanded with additional components. IceFaces and MyFaces are examples of popular add-on components.

As JSF is part of the Java standard, it is popular with development teams that want to stick to published standards for increased portability across platforms. JSF also allows existing backend Java code to be extended with a web interface without having to refactor the base application by introducing a new framework.

A simple JSF application requires a Managed Bean, Facelet, and mapping the servlet.

helloworld.java

package helloworld;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HelloWorld {

    final String world = "Hello World!";

    public String getworld() {
        return world;
    }
}

helloworld.xhtml

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelets Hello World</title>
    </h:head>
    <h:body>
        #{hello.world}
    </h:body>
</html>

web.xml

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

GWT (Google Web Toolkit)

Project Site: http://www.gwtproject.org/

Primary Sponsor: Google

GWT is much like JSF in that it is strictly focused on building web interfaces. It is more popular than native JSF as it makes it easy to maintain complex JavaScript user interfaces with Java code. GWT has lost some of its popularity over the last couple of years as more development teams are pushing Java to the backend and having it expose REST APIs which are consumed by both native mobile apps and user interfaces built in Node.js, using frameworks like Angular.

A tutorial on how to build a simple GWT application can be found on its project site: Getting Started building a GWT app.

Conclusion

In summary, there are many viable Java Web Frameworks that can be used to address your needs. None of the top three are bad choices—It comes down to personal preference. Just be aware that once you commit to a framework and start to leverage its features, switching to another framework is not an insignificant amount of work.

If you haven’t already, signup for a 14-day free trial of Rollbar and let us help you take control of impactful Java errors. :-)

Java (programming language) Spring Framework Framework mobile app

Published at DZone with permission of Vince Power, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • How Stalactite ORM Implements Its Fluent DSL
  • Spring Beans With Auto-Generated Implementations: How-To
  • Why Java Is so Young After 25 Years: An Architect’s Point of View

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!