• Post Reply Bookmark Topic Watch Topic
  • New Topic

Are scriptlets evil?  RSS feed

 
Charles McGuire
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello -

I work for a company that is just about to start down the road of JSP. We have read in several places that with JSP 2.0 scriptlets should no longer be used. The issues oft quoted are for threadsafety, readability, and maintainability by HTML editors for division of work in a MVC world.

My question is: Does it make any sense to try to outlaw, or at least severely limit, the use of scriptlets from day 1? Scriptlet functionality can be done by JST EL and custom actions.

At the risk of starting a holy war, I would like to hear from anyone that has tried to outlaw it in their shop. Can it be done? Does it make sense?

Thank you in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been outlawed here but I'm the sole writer of the Java code so it's been easy to enforce.

And, yes, it's worth the effort. The JSPs are pure HTML and Javascript with a handfull of custom tags that I've written. In our case, there isn't even any EL.

Holy wars aside, pick one boat or the other. If you are going with Model1, do it all the way, don't use EL, JSTL, or custom tags. There will be no benefit to doing so. They will just become extra technologies to have to train for and keep up with.

If you go with MVC, either with a framework or with your own architecture, then make the ban on scriptlets absolute.

Mixing the two gives you all the hassles of both and the benefits of neither.
[ January 18, 2005: Message edited by: Ben Souther ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I live with my feet in both worlds:

At my day job, we are still on JSP 1.2 and the pages, while well-factored for a model 2 architecture, contain a lot of scriptlets for display support. I've seen to it that all processing is handled by the servlet controllers, and I've instituted a lot of useful custom tags, but there's still a lot of Java goo on the pages.

For web apps that I create for my 'home business' clients, it's pure JSP 2.0. And like Ben, I have stricken scriptlets from the pages.

So, being able to compare and contrast the difference in readability, maintainability, and extensibility on almost a daily basis, I can state without any doubt that scriptless pages are vastly superior to their scripted counterparts.

Vastly.
[ January 18, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Committing to scriptless pages also really forces you to ponder your architecture and to carefully plan and think about the interface between your controllers/actions and the JSP pages.

Your web app architecture will be better for it.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37256
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Bear, we use JSP 1.2 at work. However, new pages don't use scriptlets much. There are a few exceptions, but they are minor.

Most of the scriptlets are from older pages that weren't designed in such a way that it was easy to remove all the scriptlets. We are slowly trying. I recommend trying to avoid introducing new scriptlets if you have a clean slate. Even if you can't do it all the time, it's a good goal.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have loads of JSPs here, still using 1.2 as well (still not succeeded in getting R&D (who control such things) to approve budget for testing compatibility with Tomcat 5, getting 4.1 in was hard enough).

Many pages use scriptlets heavily (too heavily IMO, but they're written by people who had no knowledge of Java or JSP until starting the project, they're learning).
I've abandoned scriptlets altogether from my pages, using JSTL almost exclusively with a few homegrown tags thrown in.
I'm now coaxing the others to try JSTL as well and it's starting to work.

We probably won't be changing the existing scriptlet hells to JSTL as this would require major changes to the controlling servlets in order to set the data to be displayed in ways JSTL can handle.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!