Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL over scriptlets

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I've been using JSTL over scriptlets over the past couple of months now , thanks to the guidance of experienced people here and am picking it up on the go . However , upon questioned by one of my peers who chose to side scriptlets citing they were more fundamental and closer to native Java. I didn't have much to say except for the fact that scriptlets are extremely outdated . I would like to ask the wise and experienced folks here whether there are any perfomance ,scalability advantages in using scriptlets to JSTL.In plain terms,as was her question . Is it really worth learning?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just because someone tries to justify doing things the wrong way doesn't make it right. It's like someone trying to create a modern TV set using vacuum tubes saying "it's closer to electricity!"

Maybe the first part this article might be helpful.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can say from experience that programming with scriptlets in JSP is harder than you would think. Sure, it's Java. But you have Java code mixed in with HTML code, and you need to close off the opening brackets in both languages independently. It's very easy to miss a closing } in your Java code, and you don't find out about that until you run the JSP and it fails to compile with a not very useful error message.

And if you're neat and tidy like me, then you try to indent the HTML properly and you try to indent the Java properly. That reduces the number of unbalanced-braces errors but it's very time-consuming to get it right. And you don't dare to let your IDE reformat your code because it won't do it right. Of course if you're a sloppy programmer then you just slap in the scriplets... but who wants sloppy programmers working for them?

Whereas JSP with JSTL is just one language. You can indent the code so you can see what's going on, and your IDE will tell you if you miss a closing tag. It's just not a horrible mess any more. I would never go back.

As for "fundamental"... who said that was a virtue? I would argue the opposite. There's a place for low-level languages, but churning out HTML user interfaces isn't that place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!