wood burning stoves 2.0*
The moose likes JSP and the fly likes Why were the old JSP tags deprecated? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Why were the old JSP tags deprecated?" Watch "Why were the old JSP tags deprecated?" New topic
Author

Why were the old JSP tags deprecated?

George Impagliazo
Ranch Hand

Joined: Sep 25, 2010
Posts: 41
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

Joined: Feb 26, 2005
Posts: 2061
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

Scriptlets. They've been discredited for over 10 years now.

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
George Impagliazo
Ranch Hand

Joined: Sep 25, 2010
Posts: 41
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

Joined: Sep 25, 2010
Posts: 41
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why were the old JSP tags deprecated?