Java EE 8 MVC (JSR-371) Example

Java EE 8 comes with a lean Model View Controller (MVC) specification for action based web frameworks JSR-371. The PDF document is 33 pages lean and pragmatic.

Project is the reference implementation and it already works well on GlassFish 4.1 daily build.

To get a feeling for the spec I implemented a simplistic example based on the ECB idea:

package com.airhacks.time.presentation;

import javax.inject.Inject;
import javax.mvc.Controller;

public class TimeController {

    Models models;

    AtomClock clock;

    public String now() {
        this.models.put("time", new Time(clock.currentTime()));
        return "/time.jsp";


The whole project with WAR and sources was pushed to

I also introduced the MVC sample in the 14th airhacks Q&A broadcast

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting

Web Apps, SPA, PWA with vanilla Java Script (ES 6+), CSS 3 and WebStandards only. As simple as possible, but not simpler. See you at: (Progressive) Web apps, Single Page Apps and WebStandards airhacks workshops at MUC airport, Winter Edition the podcast:

Stay in touch:


I think the most important thing distinguishing JAX-RS from MVC-JSR is possibility to use a session, right? Is it already possible?

Posted by PeterW on May 06, 2015 at 08:55 PM CEST #

Really ? Ten years ago with Spring I writed the same code, isn't a big innovation this mvc jsr in the 2015

Posted by Ciccio on May 07, 2015 at 04:53 PM CEST #

Is this the new way of doing mvc without any framework ? If yes it would be usefull to add in your sample a controller that can upload a file for exemple. I'm stuck because as soon as I declare my controller classes in my @ApplicationPath classe, controllers then do not work anymore as expected. And to be able to handler multipartforms I need to declare my controllers into @ApplicationPath. Is this technology mature enough to talk about it ?

Posted by lde75 on October 01, 2019 at 02:12 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments