« This just in. | Main | Another JSTL quick... »

Defending ugly old JSP.

Russell Beattie complains about the ugliness of JSP, even with the improvements of JSP 2.0. I have to agree. JSP is ugly. JSP also does very poorly in the separate-logic-from-presentation department, scoring an entanglement index of five - and JSTL does not help at all. JSP is butt ugly, but in JSP's defense:

  • It is possible for JSP source code to be valid XHTML. Russell could have done this in his mock-up example by setting a variable and then using the ${var} syntax instead of using "an embedded x:out tag within the href attribute". In theory, by validating your JSP source code as XML and by pre-compiling the JSP at build-time you can weed out a lot of potential errors.

  • Other popular web template languages are just as bad. Velocity, FreeMarker, and Tapestry's template language all have entanglement indexes of five as well.

  • The option of embedding Java code in JSP makes JSP very powerful. Like C++, JSP gives you enough fire-power to blow your entire leg off with one pull of the trigger.

  • Compiling down to Java byte code makes JSP very fast.

  • JSP is an accepted Java standard, it's built-in, it's well understood, and it's easy to find experienced JSP developers.

That last point seems important to me. Perhaps it is not justified and I'm just a Sun lemming, but I'm a little wary of Java web frameworks that attempt to completely side-step JSP.
Comments:

I'd be interested to know what you've got against Tapestry's templating. It really can't get much more minimal if you ask me. One little jwcid attribute in what otherwise is straight HTML.

Posted by Glen Stampoultzis on March 21, 2004 at 08:02 PM EST #

I have nothing against Tapestry and would consider it for my next Java webapp project. I should have said, "just as bad in terms of entanglement index." You are correct: Tapestry pages are far less ugly than JSP.

Posted by Dave Johnson on March 21, 2004 at 11:30 PM EST #

I totally agree with your last point - no matter how insane JSP syntax gets, it's still "standard" which means a lot when looking for someone to help maintain pages, etc. This is the #2 reason I don't move to Velocity. The #1 reason is that I love the xml: tags. There's no way, however, I could've made that code valid XML without using JSP 2.0-only EL on the page which I'm hesitant to do, like Matt said in a comment, until the big guys like WebLogic and WebSphere support it. -Russ

Posted by Russ on March 22, 2004 at 01:49 AM EST #

i like JSP. sure you can mix presentation and logic, but you choose not to also. you could produce XML with your JSP pages and let the html presentation be done by XSLT transforms. there are many ways to mitigate the pitfalls of JSP. but it is also nice when one of your co-workers (who are java programmers, but not web developers) can fix a problem in your JSP file because it is plain ol' java. if you start getting all funky with templating languages and every other flavor of the month, then you loose that. and that would be bad because the other java programmers don't have time to learn every new web technology under the sun.

Posted by anon on March 22, 2004 at 04:44 AM EST #

[Trackback] Russell recently posted an entry on JSP 2.0 syntax to which Dave responded, defending JSP syntax. Dave's primary defense is that: "JSP is an accepted Java standard, it's built-in, it's well understood, and it's easy to find experienced JSP developers."...

Posted by All Things on March 23, 2004 at 04:21 PM EST #

How can anyone say JSTL doesn't help? JSTL rocks! I gave up JSP in disgust 3 years ago in favor of XSLT. The separation of content and presentation doesn't get any cleaner than XSLT. But yes, you lose all that power and flexibility of JSP. Plus XPath can be very difficult and cryptic for complex selection criteria. Powerful and concise, but still cryptic, like regex. Anyhow, I'm back to using JSP because of JSTL. The x tags are obviously modeled after XSLT tags. And the core tags are ten times more usefull and well thought out than, say, Struts bean and logic tags.

Posted by Jon Tyree on April 13, 2004 at 10:10 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« This just in. | Main | Another JSTL quick... »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Java, some may be related to this entry.