You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Jon Stevens <jo...@latchkey.com> on 2001/02/09 19:33:49 UTC

You make the decision. (Mini-Essay #1)

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/>


Re: You make the decision. (Mini-Essay #1)

Posted by Jon Stevens <jo...@latchkey.com>.
on 2/11/01 8:44 AM, "Ted Husted" <ne...@husted.com> wrote:

> I'm looking forward to using this material, along with Jason Hunter's
> seminal article < http://www.servlets.com/soapbox/problems-jsp.html >,
> as background for an article with the theme "Best practices: Using JSP
> within the Struts Framework".

Jason's paper is *way* out of date and not entirely accurate any longer.

I appreciate that you are updating your document about best practices of
using JSP within Struts, however, I have some clear examples that I will be
publishing soon (thanks to Jason Hunter) that show that Struts still
violates good MVC/Pull/Model2 design principles, even with very simple
examples...we all just need to realize that making wrapper products (struts)
around bad products (jsp) is just not a good way to develop code because the
warts in the bad products will show through into the wrappers...

> Of course, my previous offer still stands:

I didn't respond, because if you look at the TDK, there are actually a
couple example applications there.

-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/>


Re: You make the decision. (Mini-Essay #1)

Posted by Ted Husted <ne...@husted.com>.
Jon Stevens wrote:
>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. 

Thanks, Jon. I agree that it is important to point-out how JSP can be
best be used, rather than taking the quick-and-easy low-road popularized
in the press. In many ways, JSP is an embarrassment of riches, and it is
* very * easy to shoot yourself in the foot. I've taken the liberty of
adding a link to your working draft from my Struts page <
http://husted.com/about/struts/ >. 

I'm looking forward to using this material, along with Jason Hunter's
seminal article < http://www.servlets.com/soapbox/problems-jsp.html >,
as background for an article with the theme "Best practices: Using JSP
within the Struts Framework".

Of course, my previous offer still stands:

On 2/6/2001 at 5:24 PM Jon Stevens wrote:
>As a result, I'm now creating an Essay titled "You make the decision."
>that will explain in detail the differences on implementing a 
>on topsystem based of Struts+JSP and Turbine+Velocity. 

On 2/6/2001 at 10:43 PM Ted Husted wrote:
>An honest evaluation could be very helpful to the community. I took a
>long look at Turbine (the TDK really rocks, by the way), but just
>couldn't get my head around it. A "rosetta stone" application
>implemented with each product would be a good start on finding ways
>the subprojects can share resources and interoperate. Of course, I'd
>be happy to collaborate.