This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I've been writing quite a lot of scriptlet lately because I've never gotten into tags atoll. I'm at a point where I really could go back and make JSTL if I thought it was worth the effort. Anybody want to convince me?
This is probably the worst, data stored in a hierarchy displayed in a table ... would JSTL be lots better?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
If some one were to ask me to maintain this code, I ll find you and then shoot you
Have a look at the foreach tag and EL. It can be sorted out that way and it is easier. The reason you should use JSTL, EL is that you are using a tag library that has already been tested and is known to be working. You have to spend effort to write scriptlet logic and then test it. Everytime you change it you need to test it again. The code is very readable also when you use JSTL+EL.
Bear has written an article about scriptless JSPs. Have a look at it.
I am also not comfortable with having so many nests in code. The max I can handle is 3, and then the nests begin to distract me from what I wanted to write the nest for .
I am also guilty of this. It is because it is my very first jsp/servlet app, and there was no standard set in my workplace, not to use scriplets. In addition, tags quite are the first ones to fly out of my memory cells.
I rationalized myself by saying that I still need to do business logics in the jsp. I think, that to improve it to use EL/JSTL/tags, I need to form the bean, after, all the business logics. Thereby not leaving any need for logical codes in the jsp.
Originally posted by Stan James: This is probably the worst, data stored in a hierarchy displayed in a table ... would JSTL be lots better?
To me, yes. If I could move all of that logic into a Java object that returns a list of row beans, I could test it from the command line or from a junit script; separate from the container. It would also, be easier (and less error prone) for a web designer with no Java experience to update the look and feel of the JSP if it looked more like this:
Also the Javadoc API for StansTableRowBean would be a good opportunity to document what this table is and what it's for. The person working with the JSP wouldn't need to know how this data was derived, just what they're supposed to do with it. If you're memory is half as bad as mine, you could be that other person trying to figure out what this table is for next year.
Your milage may vary. [ September 17, 2007: Message edited by: Ben Souther ]