velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Stevens <...@latchkey.com>
Subject You make the decision. (Mini-Essay #1)
Date Fri, 09 Feb 2001 18:33:49 GMT
Hey all, this is just the start of more coverage on why JSP sucks. I will
eventually compile these mini-essay's into an essay titled "You make the
decision." and publish it on the web somewhere (in other words, I'm
collecting information).


Key:
    "" <- quotes from the article
    [] <- editorial comments from the pain in the ass

Article:
<http://www.devshed.com/Server_Side/Jserv/JSP/>

"Now, we're big fans of Java - we've used it in the past, and will do so
again in the future - but this series of tutorials isn't about Java. It's
actually about an offshoot of Java..."

[Suddenly JSP is an "offshoot" of Java. Right there you have the problem
that people are now encouraged to write some pseudo Java in their JSP
pages.]

"And so, JSP was developed to separate application logic from the interface,
so that changes to one would not affect the other. Working closely with
developers like The Apache Group, JSP uses a tag-based approach (similar to
PHP and ASP) which allows designers to make changes to the user interface
without affecting application logic."

[Ah...now I see...they DO slightly get it...except that they compare the
"tag-based approach" to PHP and ASP which don't use a JSP style taglib
approach...hmmm...keep reading...their misstatement will become real clear
soon...]
--------------------------------------------------------------------------

<http://www.devshed.com/Server_Side/Jserv/JSP/page2.html>

[blah blah blah about scalability...]
--------------------------------------------------------------------------

<http://www.devshed.com/Server_Side/Jserv/JSP/page3.html>

"
<%
// asking for it!
out.println("Waiter, can I have a cup of Java, please?");
%>
"

[The *FIRST* example of JSP usage is embedding Java code in the page. There
we go! The earlier misstatement is now clear! They mean that because your
CODE is embedded in <% %> tags that that is taglib just like ASP and PHP!
This is *exactly* what JSP taglibs are trying so hard to avoid and no one is
getting it! LOL!

Now, take that example and try making the word "cup" in a font size of +2.
In order to do that, you need to embed HTML within your String. What will
that look like?

<%
// asking for it!
out.println("Waiter, can I have a <font size=\"+2\">cup</font> of Java,
please?");
%>

How many strictly HTML designers do you know that can properly escape a
String? On top of it, you are now no better off than creating a Servlet. The
point being is that JSP simply moves the problem around. Before you needed
to have an IDE and a compiler, now you just need a text editor.

Oh wait, the above example is the wrong way to do it. There are better
ways...the point being that articles such as this one don't bother showing
it. They show the WRONG WAY FIRST! DUUUUUUUHHHHHHHH! This is another example
of why JSP Sucks.
]

"
Every JSP statement ends in a semi-colon - this convention is identical to
that used in Perl, and omitting the semi-colon is one of the most common
mistakes newbies make. Just as an example, here's what happens when you omit
the semi-colon from the example above:

org.apache.jasper.JasperException: Unable to compile class: Invalid type
expression.
                out.println("Waiter, can I have a cup of Java, please?")
                           ^
: Invalid declaration.
                out.write("\r\n\r\n\r\n");
                         ^
2 errors"

[Ok, here is the next reason why JSP sucks. They forgot a single ;. How many
designers do you know that can properly read a stack trace that doesn't even
give a good error message as to what the problem is? This is yet another
reason why JSP sucks...it has sucky error messages because it depends on the
javac compiler to get its information.]

---------------------------------------------------------------------------
<http://www.devshed.com/Server_Side/Jserv/JSP/page4.html>

[This page simply continues the tradition of embedding more Java code into
your page. How many designers really know what a String object is? It goes
on to explain the difference between <%! and <%...gee...I wonder how many
designers understand scope?]

---------------------------------------------------------------------------
<http://www.devshed.com/Server_Side/Jserv/JSP/page5.html>

[Wow...it only gets better...now we are doing math within our JSP page and
we are embedding even more HTML into out.println() statements. I love it!
More examples of exactly why JSP sucks! The people who write the articles on
JSP can't even provide a good example of how to "properly" use JSP!]

---------------------------------------------------------------------------
<http://www.devshed.com/Server_Side/Jserv/JSP/page6.html>

[Again...yet *another* page of the exact way that you shouldn't use JSP.]

---------------------------------------------------------------------------
<http://www.devshed.com/Server_Side/Jserv/JSP/page7.html>

[This is great! An entire page showing how JSP is no better than SSI!]

"And that's about it for this week. We've shown you the basic building
blocks of JSP, and next time, we'll be using those fundamental concepts to
demonstrate JSP's control structures. Don't miss it!"

[It also is the end of Part 1 of the article...where in the next article,
they promise us to show us more thrilling examples of how to embed more
logic in our pages and completely destroy any semblance of the "Model 2" MVC
model that JSP is trying so hard to achieve.]

---------------------------------------------------------------------------

Conclusion:

Yes, it is possible to do JSP correctly in such a way to follow MVC/Model
2/Pull Model methodologies. We all know that. That isn't the point though.
The point is that very few people actually use JSP correctly. In fact, it
can be stated that JSP almost *encourages* people to do it incorrectly
because it makes it so easy to do so. Articles like this on DevShed one are
a prime example of that.

Instead, why not use technologies that encourage you to do things correctly
and actually make it easier for your HTML designers to work with?

These technologies are also available from the Apache Software Foundation,
under the same open BSD style license. In fact, not only are the
technologies 100% open, but so is the specification (unlike JSP which
requires you to sign an NDA and join the JCP).

You have a chance to more closely define what goes into your technology
instead of waiting for Sun and other corporate vendors to dictate what they
think you should do and how you should do it.

You make the decision.

:-)

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/> && <http://java.apache.org/turbine/>


Mime
View raw message