evsh.net

evsh.net header image 2

Why you should be shot if you use the JSTL SQL tags.

January 10th, 2007 by Inigo Montoya · 2 Comments

One of the many arguments Olav and I have is whether development speed, or proper engineering is “better” when developing an application. I’m of the belief that no matter how small, it ultimately is most beneficial to spend a bit of time up front building a solid foundation for the application to sit upon.

One of the areas that always gets us discussing the two different approaches is the SQL JSTL tags in J2EE.

I positively, absolutely, completely despise these tags. I have two main gripes about them:

1. The J2EE spec says: “The JSTL SQL tags for accessing databases listed in Table 14-8 are designed for quick prototyping and simple applications.” Unfortunately, that’s just asking for trouble. I don’t know about others, but from my experience, management/product development tends to see a “prototype” or a “simple application” and, if they like it, immediately want to move it to production. And then they want to begin enhancing it. Never mind if it was just thrown together in a couple of hours as a proof of concept.

To me, this is almost as if Sun hadn’t learned past lessons in releasing technologies that caused more headaches than they solved, e.g. creating JSP’s and then telling people to use a model 1 architecture. Which brings me right to…

2. These tags discourage the use of the MVC pattern. I’m willing to go out on a limb here and bet that the JSP’s in applications that make use of these tags also contain business logic, and presentation logic.

Again, this is a bad thing.

That’s why I always take the slightly longer approach of engineering a foundation for any application I work. It’s really not that difficult nowadays with the many excellent open source frameworks out there (Spring, Hibernate, etc.). There’s really no reason to just hack something together any more.

I’ve been bitten in the ass in the past way too many times by misuse of JSP’s (tag related or otherwise), so now I’ve made it a point to always lay a solid foundation for anything I build. That way, if I ever need to support and/or enhance it, I’ll know that I won’t have to go digging through JSP after JSP with embedded SQL, business logic, and presentation logic.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • scuttle

Tags: tech · java · j2ee · jstl · sql · mvc

2 responses so far ↓

  • Retrospector // Jan 11, 2007 at 2:00 pm

    This totally reminds me of an application we built in cold fusion just to get it in front of some executives at an approaching meeting. We spent a couple days tossing together a big piece of crap that barely worked but looked great, only to find out that they loved it so much they wanted us to start handing out URLs to everyone that day.

    There’s something about the instant gratification of “prototyping” that really goes the wrong direction sometimes if you aren’t prepared for it. We’ve stopped prototyping anything for show outside our group where I’m at now. We simply don’t show things unless they really ARE almost ready to deploy.

    As for the whole MVC argument…I won’t even go there. Should be shot indeed! :)

  • Greg // Jan 14, 2007 at 12:00 am

    It’s the whole “it would be so easy just this once…” philosophy, upon which a sizable percentage of Earth’s running code is built. The other extreme is embodied by militant EJB enthusiasts, and we should be equally wary of it.

    It’s like construction. A lawnmower shed only needs a six-inch-thick pad for a foundation, but it still needs a pad.

Leave a Comment