I got out of a long job that was very technologically conservative and I have been having a lot of fun getting up to date. I learned that the above tags, whatever they are called, have been deprecated in favor of the JSTL core tags.
My question is why?
For example, I do not see much advantage in doing this:
versus doing this:
The old way has the advantages of needing to know only 1 - 2 tags beyond ordinary Java sytax.
I'm not being a contrarian, I'm genuinely interested in seeing the advantage. Thoughts?
To maintain a good architectural separation of ui, business logic, db, and others if any, scriptlets should be moved to tags to cleanly separate the business logic on those.
If you are making only a few jsps, or you are not the one who will maintain those jsps you are making, go ahead and use scriptlets (and hope the maintainer is not a chain saw murderer).
Let me give you one example.
I recently made a custom tag that returns struts' current module context. After that, I used that tag in tens of jsps. Imagine, how clean that is. Just 1 line. And if I need to change the functionality of such thing, I only change the tag java code and all jsps receives the change.
I dont blame you. I also felt the same way before, until I actually worked on systems that use hundreds of jsps and servlets.
To maintain a good architectural separation of ui, business logic, db,
The examples found in the old links helped me see why the new tags would be desirable over the scriptlet tags. I keep all of my data crunching in a class and do all of my other misc java work in one block at the top of a JSP. I then only use scriptlet tags for getting values or conditional rendering. However, I know that given a chance many programers will not separate MVC and do the things I do. I've seen it. It seems like the new JSTL tags will make it harder to be sloppy. I didn't see that before, thanks for posting the links.
Joined: Sep 25, 2010
Bear Bibeault wrote:Scriptlets. They've been discredited for over 10 years now.
I don't recall any deprecated core Java API that "went away".
And technically, scriptlets aren't deprecated, they're discredited. That means that even though they aren't technically deprecated (probably because there's no formal way to do so as there is with the Java API), their use is strongly discouraged.