Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsps for micro functionality?  RSS feed

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36396
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of my book reviews, I included:
However, I took issue with two of the statements in the book. Page 99 says “despite most books and blogs recommending JSF over JSP.” Maybe they mean over just JSP vs servlets/JSP (MVC). Page 107 says about scriptlets “If used judiciously, scriptlets can save a lot of time and effort, but if used too much....”. The chapter then describes <%! %>, <% %> and <%= %>. All of these have been considered bad practice for a decade.


The author responded with:
I wonder if you are being a bit too harsh on JSP. I suppose there must be a reason why "bad practice" tech is still part of Java EE and has been used for over a decade.
I find JSPs quite useful for micro functionality where there's not much of a frontend but just some quick serverside work to be done.


I'd like to discuss this a bit here. One reason scriptlets have been used over a decade is that books keep telling people to use them. Even if he is right about having a use case, I stand by my review though. The disclaimer is nowhere near powerful enough.

I'm thinking about the micro functionality use case he brings up. The only one I can think of is for doing some sort of troubleshooting and needing the ability to get different pieces of data without restarting the app. And even then, I wouldn't be using <%! %>.

Thoughts?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose there must be a reason why "bad practice" tech is still part of Java EE and has been used for over a decade.

That seems a specious argument. Java EE includes various functionalities that are outdated and should no longer be used, e.g. the JAX-RPC API; it calls them optional. And Java SE has never removed even a single API, no matter how obsolete or broken it was. So even while the spec doesn't refer to scriptlets as obsolete or optional, their mere presence does not mean they should be used.

I think scriptlets are useful in helping people get started with Java web apps by allowing them to quickly set up dynamic pages without having to declare servlets, learning about JSPs and EL etc., and providing a quick compile/run/debug cycle simply by reloading the page. Anyone frequenting these forums will be familiar with how much beginners struggle with all these aspects of Java web apps; being able to write web pages using just Java -which they are familier with- helps them get started more easily. Once they become more proficient developers they should stop using them. I think anyone who's been programming for a while will have plenty of code from their early efforts that they would later be embarrassed to own up to; scriptlets are part of that.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My stance on scriptlets is well-known. And like Ulf, I'm not buying the "we've always done it that way" argument.

Like-wise, I think that the "micro" argument is thin -- it's the camel's nose under the tent. Something that starts off as a "micro" element is likely to grow over time -- we all know how that goes -- and become a bigger problem before one knows it.
 
Dave Tolls
Ranch Hand
Posts: 2504
27
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
I think scriptlets are useful in helping people get started with Java web apps by allowing them to quickly set up dynamic pages without having to declare servlets, learning about JSPs and EL etc., and providing a quick compile/run/debug cycle simply by reloading the page. Anyone frequenting these forums will be familiar with how much beginners struggle with all these aspects of Java web apps; being able to write web pages using just Java -which they are familier with- helps them get started more easily. Once they become more proficient developers they should stop using them.


I've found the opposite, in that people end up picking up bad habits. I'm not a fan of teaching people those habits and then attempting to remove them...even with the help of a stick.

Ulf Dittmer wrote:
I think anyone who's been programming for a while will have plenty of code from their early efforts that they would later be embarrassed to own up to; scriptlets are part of that.


Oh yes, indeed.
Sadly some of my earliest stuff is out there on warships...*eek*
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!