Off topic, and on soapbox: Vector and logic:iterate?!? It's 2004, List/ArrayList have been part of the JDK for yonks to replace the ill-conceived legacy collection classes, and the vastly superior JSTL has made the Struts logic tags instantly obsolete, what, two years ago or so? Why is anybody still using this?
Joined: Nov 22, 2008
can I use JSTL tags in a struts program ? if so I need some sample
Yes, you can use JSTL tags in a "Struts Program." JSTL tags are like any tag library that you import. Struts does not prevent you from using any other tag library.
Peter den Haan
Joined: Apr 20, 2000
Originally posted by Marc Peabody: Maybe logic:iterate is still being used because JSTL isn't all that vastly superior.
Do you really think so? The Struts tags have no serious expression language support, have only a limited ability to plug into each other the way the JSTL tags can, and as far as iteration goes the LoopTagStatus object alone is already worth the price of admission (see the c:forEach varStatus attribute). And last but not least the Struts team encourages their users to choose the JSTL over the Struts tags. It seems to me that the Struts logic taglib has been dead ever since the JSTL became mainstream and it never ceases to surprise me how many people are still interested in the corpse
I can't disagree too much with your case on Vector, although it may have been worth giving a brief explanation of why to not use it other than to flame it for being old.
It wouldn't surprise me if my rants about the old-style collection classes numbered in the triple digits by now, so you'll have to forgive me if explaining it gets a bit old. Point taken, though: that is still no excuse for the guerilla sniper style of posting I employed above. My apologies.
There's been a feature-complete Collections Framework since Java developers went around in bear skins and carved their software in flint punchcards - since JDK 1.2, to be precise. Use it. The legacy classes ('cause that's what Sun calls them - read the collections doc in the SDK!) Vector, Hashtable and Enumeration are just needless intellectual baggage. Forget them until you have to program against a legacy API.
The legacy collections have been forcibly retrofitted with the Collections interfaces, which makes their API hopelessly inconsistent and confusing. What shall I use to iterate over my Vector today, an Iterator or an Enumeration? Give a Vector or Hashtable to different developers and they will use different methods. Unless they're smart enough to know that they should only program against the List (or Map) interface.
Vector and Hashtable are synchronized. Most of the time these objects are used in a single-threaded fashion and this is completely unnecessary overhead.
And when you do require multi-threaded access... the synchronization is in almost all cases totally useless and still completely unnecessary overhead. You see, most of the time it's not the little Vector methods that need to be atomic with respect to other threads, but the more coarse-grained business operations that you write using the Vector.
It gets worse. I have seen too many cases where inexperienced developers think their code is threadsafe because they use Vector (or Hashtable), and "Vector is threadsafe". They get lured into a false sense of security and I don't want to know how many subtle concurrency problems made it into production because of this.
If you happen to hit one of the rare cases where you need a synchronized collection, use the wrapper methods in Collections.
Do you seriously think Josh Bloch et al didn't know exactly what they were doing when they introduced ArrayList and HashMap into a JDK which already had Vector and Hashtable?
- Peter [ August 23, 2004: Message edited by: Peter den Haan ]