Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
 
friki data migration
Ranch Hand
Posts: 772
  • Mark post as helpful
  • send pies
  • 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 2014, that is over 12 years ago! If you are still using scriptlets in JSPs, you are 12 years behind the times.

12 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 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 12 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.



    JspFaq
     
      Bookmark Topic Watch Topic
    • New Topic