JSP 2.0 was introduced in 2002 with the JSTL and EL intended to replace Java scriptlets in JSP pages. 2002! Almost 12 years ago! If you are still using scriptlets in JSPs, you are 12 years behind the times.
Java scriptlets have been obsolete and discredited since the introduction of JSP 2.0 and there are many good reasons not to use Java scriptlets in JSPs including:
- Separation of Concerns - Best practices dictate that presentation logic and business logic should not be mixed.
- Reusability - How would one use code in a JSP over again in subsequent JSP pages or Java classes?
- Maintainability - A database column changes and you will be hunting through all your JSPs for places to change. Better to do this in Java classes lets where it can be easily refactored.
- Scriptlets Break OOP - scriptlets cannot be extended or encapsulated.
- Getting business logic out of JSPs lets you take advantage of the Java bean paradigm
Due to the above, a developer using scriptlets is a clear warning sign that a developer:
- Is not serious about their craft
- Does not know what they are doing
- Does not care to follow best practices
- Has not updated their skills in over 10 years
- All of the above
Do you want this to be you?
This Javaranch Journal article explains the evolution of modern best practices with regards to web application structure.