Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL vs Scriptlet again

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the nesting won't go away. The data is the data.

Right now I'm looking to see if we even have JSTL in our standard setup. Anybody know if it ships with WSAD/WebSphere 5.1? If not, I'll have to see if it's on our Open Source list.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic