I would recommend:
- Once students are ready for the backend, switch to using a minimalist framework such as Spark. Have them first construct HTML using plain old string concatenation, make a big deal over how sucky that is, then switch to using a templating engine (any one will do, so it's probably best to pick one with the best documentation).
Teaching the front-end first does require you to make a "clean break" and switch away from Java, but I do think it's for the best for several reasons:
- It's essential context for the students to have. Many backend tutorials will assume you already have a good understanding of the frontend, so it'll likely be more confusing if you don't start with the frontend.
- Starting from the frontend lets students get instant gratification.
- Starting from the frontend lets you move from simplicity to complexity: you start with static websites and gradually progress to something more complex (dynamic page generation, AJAX hijinkery, etc...).
I like using micro-frameworks such as Spark (for Java) or Flask (for Python) for teaching the backend. There's minimal ceremony, and micro-frameworks tend to closely mirror the HTTP request-response model, minimizing conceptual overhead. And since Spark is Java, you don't need to spend unnecessary time teaching a similar language.
In fact, there's even an argument to be made that the best thing to do is to ditch even micro-frameworks and start with just plain CGI or something: you literally manipulate strings, and that's it. Then, time permitting, you have students write their own framework/templating engine/what-have-you on top of that.
Basically, I view web development as one giant exercise in working with abstractions, and I feel one of the best ways to make students understand an abstraction is to have them build it from the ground-up/start without the abstraction. Web frameworks and trends come and go at a ludicrously fast pace, so I think it's particularly important in web development to focus on the fundamentals rather then trends. (You can see more about this philosophy here)
In particular, I like emphasizing that web frameworks are just complex ways of processing and sending strings: I think it helps demystify a lot of things, and gives students a concrete footing to help build their understanding of these abstractions.
(Tangent: you can work in all kinds of interesting CS topics depending on how much you want to commit to this "build everything yourself" model. For example, you can talk about compilers, parsers, and DSLs if you have students build their own templating engine; you can talk about NFAs, DFAs, regexes and such if you have students build their own regex engine to match routes... This is all probably overkill if your focus is just on teaching web development though.)