Server Side MVC vs. Plain JSP/JSTL: Overblown vs. Underutilized

I'm not saying that server-side MVC is bad, but when idiots start using the complexity of MVC and of J2EE in general as a whip against Java, I start to get a bit annoyed, both with the bozo who doesn't know anything about the power of Java and with the status quo for pushing overly-complex methods as a one-size-fits-all solution. There are lots of places where MVC solutions (Struts, WebWork, etc.) fit really well, but they've got real overhead both in development time and complexity. What I want to say here loudly and clearly is that there's nothing wrong with more basic ways of developing websites using server side Java.

As I've pointed out numerous times before, both this site and Mobitopia are both being run on about five really, really badly written JSP scripted pages which beat the hell out of a MySQL database on every request and I've never had any problems in over a year. Between the two sites, I'm serving around 500,000 page views a month. That's 15,000 times a day that these JSP pages need creak through crufty code and pump out HTML. On a 999Mhz Celeron server no less. It's not Yahoo, but hell, it's nothing to ignore either.

Now I'm not talking about returning to the Spaghetti-Code-JSP-Hell past. What I'm talking about is simple server-side Java development using JSTL, servlets and custom tags for developing fast, relatively robust websites. As I'm developing a new system for both this site and mobitopia, I'm doing it using MVC and Struts and many times I'm astounded at the complexity I'm adding. Though I'm using MVC plus some special XML sauce for specific reasons (to better support multiple mobile xml-consuming devices), I'm constantly gnawed at by the feeling that I could've been done months ago with a simple servlet and JSP pages querying the database using JSTL's SQL tags. If you haven't had a chance to play with them yet, you'll be astounded at how fast you can get pages up and running with them.

"But that's not THE RIGHT WAY" you can hear the alpha-geeks bleat! Fine, it's not "right" and so isn't PHP. But hell, slap together a bunch of read-only queries with the JSTL tags, cache it with OSCache or Jakarta Cache TagLibs and you'll have just a scalable solution as many out there. Need to have some more server side logic? Use *servlets* for how god intended them: Post data to the servlets with an "action" parameter that tells which method to call within that servlet before forwarding to the right jsp page for display and you're done. Fast development time, scalable as hell and 100% Java.

But what about maintainability? What about it? If you start adding features all over the place, then hell, rewrite it again. It took 4 days to put the whole thing together in the first place, no? And hell, 80% of the apps out there aren't created to be the next big web portal or the basis for thousands of lines of code, they're being created to do some inter-departamental function or somebody's weblog or something. These apps don't *NEED* the world's greatest scalability or maintainability.

It's all about being practical with the technology at hand and realizing that TIME is as important a resource as hardware and bandwidth. If you can slap 5 .jsp pages down which use JSTL to query a DB, then DO IT in 10 minutes if it solves the problem at hand. It all goes back to Extreme Programming (XP) in many ways: Simplicity and Never Add Functionality Early. MVC is all about separating the layers, preparing your web app for the eventual day when you start moving your view around or you need to modify your model and don't want to touch your views or who knows what. But the fact is that *this day usually never comes*.

I don't know crap about PHP, I'll admit. But I bet you that JSP + JSTL can be just as productive as PHP and just as scalable. And later if you need to use the power that Java can provide - and it *can* provide power, look no further than eBay for proof - then that option is there. It's ridiculous how many PHP-based web apps are available for download out there compared to Java-based web apps, and it's ridiculous that Sun is promoting PHP as some sort of alternate scripting solution when basic Java will do the job just fine if they just started spreading the word for Java programmers to stop over architecting simple-ass apps.

That's really the key. Sun and other Java-centric companies needs to start deliniating on those different levels of programmers and programs. They'll never get to that 10 million developer mark until they do.

Ok. </rant>


< Previous         Next >