July 17, 2005
design ne good

JSP is a way to insert Java code into HTML pages, right? This frightening JSP code fragment (from here) contains two programming languages: the language of the Java Standard Tag Library (JSTL) and Expression Language (EL).

<c:if test='${empty sessionScope["cart"]}'>
 <c:if test='${body ne "ThankYou.jsp"}'>
  <c:redirect url="ChooseLang.jsp"/>

Neither of the programming languages used is Java. And there doesn't happen to be any HTML.

What kind of person thinks this is OK?

Posted by jjwiseman at July 17, 2005 10:54 PM

No kidding! Ever try to teach two un-motivated interns to make JSP pages? You can't even explain what, much less what. Best to close your eyes and think about something else.

Posted by: on July 18, 2005 12:31 AM

Like the above, I have seen several languages, code snippets, etc. that try to emulate Lisp syntax in a bad way (XML, Water, Curl, now this, etc.). Maybe it is time for someone to set up a gallery of this kind of thing. A kind of "Greenspun Gallery of Horrors". New code sightings could be added when they appear.

Posted by: Illuminatus on July 18, 2005 02:25 AM

The Evolution of Language:

Posted by: michaelw on July 18, 2005 02:36 AM

It's frightingly ugly and utterly bad. But JSP's that are full of embedded Java are in the end even uglier and imho unmaintainable. I took me a while to get used to JSTL and EL though.

In the Spring framework this kind of coding works 'well' with the 'for-free' object-to-form-mapping. I hate it to bits, but at least I can understand the structure of the JSP's a week after I wrote them ;-)

But damn, give me LSP's or CL-WHO over these sinful practices anytime !

Posted by: Nicky Peeters on July 18, 2005 03:41 AM

Quoted from cliki (regarding jw's lsp):
"See http://sourceforge.net/projects/lsp for a more serious attempt at doing this right, by Sunil Mishra and Tim Bradshaw."

Posted by: on July 18, 2005 06:12 AM

Is it a coincidence that LSP also stands for "Language for Smart People" ... or am I imagining that?

Posted by: me on July 18, 2005 07:40 AM

it is horrifying, but if you need to put variables and control statements in a HTML page (which you will need to do at some point), how else are you going to do it?

The other approaches (templates, routines spitting out chunks of HTML) become equivalently tasteless when non-trivial logic is required when displaying your HTML.

The best solutions I've seen are 1995's AOLServer and 2005's RubyOnRails.

I've worked with most web toolkits and when dealing with HTML you will necessarily run into at least one part of your program that is a complete kludge.

Trying to solve this problem is pointless because the entire point of building web systems has (d)evolved into getting your shit out there as quickly as possible. You get your prototype out there, and if it takes off, outsource the JSPs to India and spend your time working on y-combinators or whatever it is Lisp people do other than pointing out aesthetic problems with other languages.

Worse is usually faster, hence better, when developing web apps.

Posted by: half empty on July 18, 2005 07:51 AM

Don't forget that the JSP concept was created in response to Microsoft's ASP technology. From bad to worse....

Posted by: gavin on July 18, 2005 08:31 AM

So what would be the Lisp (or better) way of writing this code? As someone earlier pointed out, code tends to get uglier when complicated logic is put into the page to decide what is displayed and what is not.

Posted by: sujeet on July 18, 2005 09:34 AM

So what would be the Lisp (or better) way of writing this code?

I'm a big believer in separating the programming from the html. In webactions it would be something like



(def-clp-function cart_chooselang (req ent args body) ...)

in the correct place, in the source code for the server.

Posted by: Kevin Layer on July 18, 2005 10:22 AM

Some people actually think this is a good thing. Witness the horror that is Jelly (http://jakarta.apache.org/commons/jelly/index.html)

Posted by: staze on July 18, 2005 10:33 AM

no discussion of the dark side of JSP/ASP is complete without the mention of PHP. There. I did it.

Posted by: J Donald on July 18, 2005 02:02 PM

This "c:redirect" seems to be a redirect. So there's no need to let the template itself decide. It could be handled some levels earlier.

Posted by: Stefan Scholl on July 19, 2005 12:03 AM

The requested URL /commons/jelly/index.html) was not found on this server.

Why do I feel like I just averted unspeakable horrors?? :-)

Posted by: David Mercer on July 19, 2005 02:32 AM
Post a comment

Email Address:


Unless you answer this question, your comment will be classified as spam and will not be posted.
(I'll give you a hint: the answer is “lisp”.)


Remember info?