• Post Reply Bookmark Topic Watch Topic
  • New 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why were the old JSP tags deprecated?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.






 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/414294/JSP/java/scriptlets-Vs-EL-JSTL

https://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.

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesus Angeles wrote:https://coderanch.com/t/414294/JSP/java/scriptlets-Vs-EL-JSTL

https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic