This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why were the old JSP tags deprecated?

 
George Impagliazo
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;

Do these JSP tags have a formal name?:



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?

Thanks.






 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/414294/JSP/java/scriptlets-Vs-EL-JSTL

http://www.coderanch.com/t/292479/JSP/java/JSTL-vs-Scriptlet-again

You should not put stuff like that in JSP.

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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scriptlets. They've been discredited for over 10 years now.

Read the intro to this article for some of the reasons.
 
George Impagliazo
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesus Angeles wrote:http://www.coderanch.com/t/414294/JSP/java/scriptlets-Vs-EL-JSTL

http://www.coderanch.com/t/292479/JSP/java/JSTL-vs-Scriptlet-again

You should not put stuff like that in JSP.

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.
 
George Impagliazo
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Scriptlets. They've been discredited for over 10 years now.

Read the intro to this article for some of the reasons.


Bookmarked! Thankyou!

That brings up another question that occurred to me today.

I've been doing Java since 1999. I can't recall ever seeing a depracated item actually become unusable. Does it happen?
 
Tim Moores
Bartender
Posts: 2795
38
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
George Impagliazo wrote:I can't recall ever seeing a depracated item actually become unusable. Does it happen?

Not in Java SE, so far. I think JEE is about to pull the plug on a few APIs (meaning, they will be optional to implement for JEE servers).

Some 3rd party libraries, notably Lucene, regularly remove deprecated classes and methods in major releases.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic