peru cheppanu wrote:
Thanks for replying me.
The basic idea is knowing the need for tag libraries.. for which the
explanation was given as reusability.
In my opinion, the purpose of tags, besides reusability (after all,
plain objects and methods are reusable and easier to implement), is
rendering the JSPs more readable and understandable by programmers more
familiar with HTML. But this is true not only if assuming that one
working with the JSPs is "java challenged". And to demonstrate this I
suggest the following experiment. Take a JSP (say medium sized) and make
2 versions of it: one using the logic tags and the other using java
scriptlets instead (the replacement should be straightforward). Then
compare the 2 versions - the more readable one should be obvious. :-)
Now, coming to specific example I have given:
I agree that it should not be a part of logic: library. But, I think
one such tag (substring) is useful in some cases.
Why not prepare the data in the form required by the view before getting
there? Usually doing so in a custom tag requires for more intermediary
steps to be done. And, as already suggested, maybe someone out there
already made such a "handy tools" tag library that has one custom tag
which does substring.
Say I need to populate a 40 * 10 table with two variables in each
cell. I will need a object array of size 400 with two parameters in
it. ( I can have Hashmap if I have identical keys, but say thats not
the case either). Instead I can have 400 String objects sent with some
delimeter. I will save lot of object instantiations and substring the
ones with two params. What do you think?
I think that in the end, by doing substring in the jsp, you'll have even
more objects created for each cell: the original string with the
delimiter and two strings representing your needed values after
extracting them. Remember that String is immutable and .substring()
creates a new one when you call it on an instance.
If all you have to do with each the values pairs is showing it in a
table cell, why don't you just concatenate the values using a space as
separator and then just display the string in the cell?
Anyway... this kind of potential problems solving should be left aside
initially when you design and develop your application. Otherwise it
could really prevent you on concentrating on the business logic and
model and postponing your delivery date. This kind of performance
problems should only be addressed at the end, **if** they really show up
as performance bottlenecks. You could be surprised by how fast java
is... ;-)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]