In the beginning web pages are static, enter CGI/ASP/JSP or whatever server side program to insert logic to generate HTML.
In the beginning there was HTML, then the world wants to define their own tags. Enter XML.
How about XML intermixed with programming? You may have seen the pure ugliness of this in the form of XSL. But XML/XSL are data and translating data. Though ugly, but it hasn't yet mess with traditional programming. The crave for your own tags doesn't stop here. JSP allows you to create your own tags in tag library. If you let people create your own tags people WILL do it, and eventually becomes standardized.
The Java Standard Tag Library (JSTL) is like a tag-based
programming language! Note: This is hardly new, actually it has come out for several years. I run into it because it seems the industry is embracing it.
All the Spring Framework examples I see uses JSTL.
JSP already provides convenient insertion of Java code within HTML. JSTL merely makes programming harder by changing syntax.
<%=variable%> prints out a variable. Nice and intuitive.
Does the following JSTL equivalent makes it more convenient?
<c:out value="${variable}" />
Of course, in order for this to work you need to import the JSTL tag library.
Actually, this is equivalent to <%=pageContext.getAttribute("variable")%>)Look, variable also has no type associated with it, and I thought one advantage of Java is strongly typed.
No one needs the extra syntax. That $ reminds me the horror of BASIC and PERL.
But wait there is more, you can even do if statements and switch statements, even iterator loops, all with different syntax than regular JSP! Oh my, for conditions, you can even use lt, gt, ne, eq like good old Fortran!
The implementation of the taglib simply change it back to the java scriptlets. Why fuss with it?
See these links for details
http://www-128.ibm.com/developerworks/java/library/j-jstl0211.html
Java builds on the syntax of C and C++. A generation of programmers are used to its syntax, we don't need to add XML tags around them.
I already object to the new for loop of Java 5 (which looks like mathematicians's for every element in a set notation).
We don't need generics (templates) from C++ either. If you let people do templates, everything will be littered with templates! If you let people do their own tags, they will use it all over. It is already hard to track down JSP typos, a good IDE may help you detect what's wrong. But it will be much harder to track down the non-java tags in JSTL. I see it not making programming JSP any easier.
No comments:
Post a Comment