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?
It's been outlawed here but I'm the sole writer of the Java code so it's been easy to enforce.
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 ]
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.
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.
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.