aspose file tools*
The moose likes JSP and the fly likes JSTL vs Scriptlet again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL vs Scriptlet again" Watch "JSTL vs Scriptlet again" New topic
Author

JSTL vs Scriptlet again

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

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 .


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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

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

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL vs Scriptlet again