Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
JSP 2.0 was introduced in 2002 with the JSTL and EL intended to replace Java scriptlets in JSP pages. 2002! In 2017, that is over 15 years ago! If you are still using scriptlets in JSPs, you are 15 years behind the times.

15 years!

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:

  • Readability - There are already enough syntaxes in web pages -- HTML, JavaScript and CSS. Using JSTL tags in the view just makes pages easier to read without a lot of Java code jumbled into them. Keep the Java code in Java classes where it belongs.
  • Separation of Concerns - Best practices dictate that presentation logic and business logic should not be mixed.
  • Reusability - How would one reuse the Java code in a JSP in another JSP page or in a Java class?
  • 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 15 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.

      Bookmark Topic Watch Topic
    • New Topic