| Author |
Scriplets Over-use
|
Gregg Bolinger
Sheriff
Joined: Jul 11, 2001
Posts: 15040
|
|
I am learning JSP and am wondering if someone could provide me with a link or resource of some sort that specifies a "rule" as to when to use a servlet instead of a scriplet? Simply, at what point do we take our scriplet and decide it needs to be a servlet? Thanks.
|
My Blog | DZone Articles
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
I don't know of any site that list such "rules", and you're likely to get a LOT of opinions on this, but here's the very loose rules of thumb I use for my own code: 1. As much as possible keep scriplets off the page 2. I almost exclusively use a model 2 approach and perform any processing in a servlet that forwards to the JSP with all the "hard work" already done 3. Any scriplet that DOES appear on the page should be there as a "display helper"... e.g. formatting, iteration, and so on. If the scriplet does "real work" it goes in the servlet. 4. If the scriplets start forming a pattern used over and over again, or if it's something that's complex and makes the page look really gnarly, it gets factored out into custom tags. Pretty loose, I know, but it seems to work to keep my pages pretty simple and easy to maintain/extend. hth, bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Gregg Bolinger
Sheriff
Joined: Jul 11, 2001
Posts: 15040
|
|
|
Thanks Bear. So if I may ask, can you expand a little on your approach to writing a Custom Tag over putting the code in a scriplet?
|
 |
 |
|
|
subject: Scriplets Over-use
|
|
|