The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Marital problems with JSTL

After a long honeymoon phase there are some things about JSTL that really bug me. I absolutly love the way JSTL looks, all slim and lean. WOW. No excesive code creeping out here or there like scriptlets. My problem is with the output. I like neat and orderly output. I like to know what to expect. It's great for troubleshooting HTML. With a little guidance, scriptlets generate very nice output, as nice as hand-coded HTML. There is an element of separation in the markup. "<% if (...)" does not look like "<name". Scriptlets and HTML look different and are structured in different ways. There is no concern about nesting them, so long as the output looks good, if that's important to you. The following is acceptable to many developers:

    <% if (true) { %>
                    <div id="...
    <% } %>
                    <div id="...
                    <div id="...

The result is:
                    <div id="...
                    <div id="...
                    <div id="...

JSTL and HTML look alike, yet are functionaly different. "<c:if" is similar to "<name". I should never see JSTL markup in my HTML output so why should I indent them in the source code as if they were one? I demand output the way I expect it. This often means the source markup isn't "properly" nested, or is it properly nested because the output HTML is indented the way I expect?

    <c:if test=...
    <div id=...
    </c:if>
    <div id=...
    <div id=...

The result is

    <div id=...
    <div id=...
    <div id=...

Many developers prefer the following for the sake of "proper" indentation:

    <c:if test=...
        <div id=...
    </c:if>
    <div id=...
    <div id=...

The result is:

        <div id=...
    <div id=...
    <div id=...

BLAH!
How does one deal with this canundrom?
Enonymous
Friday, April 21, 2006
 
 
I tend to do as follows, aligning the {}s with the level they're in, rather than further indenting:
<html>
  <body>
  {if $test}
    <div id="blab">Content</div>
  {/if}
    <div id="blab2">More content</div>
  </body>
</html>

it falls down when you have nested conditions but no html:
{if $test}
  {if $test2}
    <div id="thing">...
  {else}
    <div id="thing2">...
  {/if}
{/if}

but I'm generally not concerned with the formatting of the output, not enough to spend time worrying about it :)
G Jones
Friday, April 21, 2006
 
 
I got some counseling and discovered JSTL does not indent code the way I thought. I was getting things mixed up with xml and XSLT. JSTL only leaves space above and below the conditional HTML output but everything really is indented properly. There probably is a setting to deal with the space above and below, but that doesn't bother me. JSTL and I are okay now. Thanks and I hope you enjoyed this brief demonstration on how advancing technology and the evolution of computer languages is improving our lives and making things easier.
Enonymous
Friday, April 21, 2006
 
 
New thread direction:
If something is easier, but more confusing to master, is it an improvement?
Enonymous
Friday, April 21, 2006
 
 
Even newer thread direction:

Why do you care about the indentation of the markup produced by your JSP code?
BenjiSmith Send private email
Friday, April 21, 2006
 
 
Caring about the indentation of generated HTML is a lot like caring that your compiler outputs nicely sorted .obj files.
Chris Tavares Send private email
Friday, April 21, 2006
 
 
"If something is easier, but more confusing to master, is it an improvement?"

I am of the opinion that very few new things are improvements. I think we're looking at buzzword churn here.

Do the people who hype some new technology that just swaps new problems for old really have our best interests at heart?
Rowland
Tuesday, April 25, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz