You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Woodchuck <wo...@yahoo.com> on 2004/08/27 19:21:58 UTC
philosophical question/poll about Struts/JSTL, scriptlets
sorry to bring this up on a Friday...
does everyone here have pure Struts/JSTL jsp pages that is absolutely
void of scriptlets?
or do you have jsp pages that use a combination of Struts/JSTL and
scriptlets, all living together harmoniously using whichever method is
easiest/cleanest?
is mixing Struts/JSTL with traditional scriptlets a bad thing?
i have to say that i would prefer to *not* mix scriptlets with
Struts/JSTL but in some situations it seems scriptlets is the better
solution (in terms of code maintainability). that is, it would be
easier to use a little snippet of scriptlet here and there instead of
making a round-about (albeit clever) and more verbose way of doing the
same thing without scriptlets...
any opinions is welcome! i want to be able to sleep without nightmares
about this!! :)
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Michael McGrady <mi...@michaelmcgrady.com>.
I have not heard of the 80/20 view. I definitely spend the majority of
my time coding: I would be more like 10/90. However, on most design
issues, the ideas in circulation are the ones I use and I don't have to
reinvent the axel. (Why people talk about reinventing the wheel is a
mystery to me. Any idiot can invent the wheel. The axel, now that is
another matter.)
Michael
Woodchuck wrote:
>
>i agree. i have also unexpectedly found benefits from this too. i try
>to do my best to organize my code and adhere to the principle of
>separating business logic from presentation logic (model from view).
>i'll be the first to admit that this is hard and not obvious from the
>get go most of the time, but i try. i still believe in 80/20 rule
>where 80 should be design and 20 should be actual coding. it is quite
>conceivable to me that if you've thought out a very good design that it
>could be even 95/5! :) there is nothing quite as enjoyable as
>whipping through code because the design was great and everything falls
>into place as planned.
>
>someone else also mentioned a good point earlier. if the code begs to
>have scriptlets then it maybe a sign that there is something wrong with
>the design of the page, assuming the scriptlet was not trivial but
>contained some degree of business logic in it.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Woodchuck <wo...@yahoo.com>.
--- Michael McGrady <mi...@michaelmcgrady.com> wrote:
> Woodchuck wrote:
>
> >hehe, you make it sound as if scriptlets are the ball and chain and
> >shackles that you are free from!
> >
> >no doubt that scriptlets can easily fit that description, but i
> guess
> >what i'm referring to are 'nice' scriptlets :)
> >
> >little tiny scriptlets that are hands down easier than than the
> >would-be non-scriptlet alternative
> >
> >i think this topic is a mix of pragmatic views and philosophical
> >views..
> >
>
> To me it is all practical or nothing. However, there are positions
> that
> seem philosophical and in fact in practice turn out to be of concrete
>
> value. The separation of functions and the decoupling of things in
> programming, in my view, always has paid off huge dividends and paid
> them off in areas where they never were suspected.
>
i agree. i have also unexpectedly found benefits from this too. i try
to do my best to organize my code and adhere to the principle of
separating business logic from presentation logic (model from view).
i'll be the first to admit that this is hard and not obvious from the
get go most of the time, but i try. i still believe in 80/20 rule
where 80 should be design and 20 should be actual coding. it is quite
conceivable to me that if you've thought out a very good design that it
could be even 95/5! :) there is nothing quite as enjoyable as
whipping through code because the design was great and everything falls
into place as planned.
someone else also mentioned a good point earlier. if the code begs to
have scriptlets then it maybe a sign that there is something wrong with
the design of the page, assuming the scriptlet was not trivial but
contained some degree of business logic in it.
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Woodchuck wrote:
>hehe, you make it sound as if scriptlets are the ball and chain and
>shackles that you are free from!
>
>no doubt that scriptlets can easily fit that description, but i guess
>what i'm referring to are 'nice' scriptlets :)
>
>little tiny scriptlets that are hands down easier than than the
>would-be non-scriptlet alternative
>
>i think this topic is a mix of pragmatic views and philosophical
>views..
>
To me it is all practical or nothing. However, there are positions that
seem philosophical and in fact in practice turn out to be of concrete
value. The separation of functions and the decoupling of things in
programming, in my view, always has paid off huge dividends and paid
them off in areas where they never were suspected.
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Woodchuck <wo...@yahoo.com>.
hehe, you make it sound as if scriptlets are the ball and chain and
shackles that you are free from!
no doubt that scriptlets can easily fit that description, but i guess
what i'm referring to are 'nice' scriptlets :)
little tiny scriptlets that are hands down easier than than the
would-be non-scriptlet alternative
i think this topic is a mix of pragmatic views and philosophical
views..
--- Michael McGrady <mi...@michaelmcgrady.com> wrote:
> How much wood could a woodchuck chuck if a woodchuck could chuck
> wood?
> I have freed myself of scriptlets on all pages except my entry page.
> I
> just have not bothered to clean up the entry page as yet. I think
> getting rid of them is a good philosophical position but it is so
> because the result practice is SOOOOO much better. The issue is
> really
> more pactical, as you suggest, than philosophical. Screw the
> philosophy
> if it does not work.
>
> Michael
>
> Woodchuck wrote:
>
> >sorry to bring this up on a Friday...
> >
> >does everyone here have pure Struts/JSTL jsp pages that is
> absolutely
> >void of scriptlets?
> >
> >or do you have jsp pages that use a combination of Struts/JSTL and
> >scriptlets, all living together harmoniously using whichever method
> is
> >easiest/cleanest?
> >
> >is mixing Struts/JSTL with traditional scriptlets a bad thing?
> >
> >i have to say that i would prefer to *not* mix scriptlets with
> >Struts/JSTL but in some situations it seems scriptlets is the better
> >solution (in terms of code maintainability). that is, it would be
> >easier to use a little snippet of scriptlet here and there instead
> of
> >making a round-about (albeit clever) and more verbose way of doing
> the
> >same thing without scriptlets...
> >
> >any opinions is welcome! i want to be able to sleep without
> nightmares
> >about this!! :)
> >
> >
> >
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Take Yahoo! Mail with you! Get it on your mobile phone.
> >http://mobile.yahoo.com/maildemo
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Michael McGrady <mi...@michaelmcgrady.com>.
How much wood could a woodchuck chuck if a woodchuck could chuck wood?
I have freed myself of scriptlets on all pages except my entry page. I
just have not bothered to clean up the entry page as yet. I think
getting rid of them is a good philosophical position but it is so
because the result practice is SOOOOO much better. The issue is really
more pactical, as you suggest, than philosophical. Screw the philosophy
if it does not work.
Michael
Woodchuck wrote:
>sorry to bring this up on a Friday...
>
>does everyone here have pure Struts/JSTL jsp pages that is absolutely
>void of scriptlets?
>
>or do you have jsp pages that use a combination of Struts/JSTL and
>scriptlets, all living together harmoniously using whichever method is
>easiest/cleanest?
>
>is mixing Struts/JSTL with traditional scriptlets a bad thing?
>
>i have to say that i would prefer to *not* mix scriptlets with
>Struts/JSTL but in some situations it seems scriptlets is the better
>solution (in terms of code maintainability). that is, it would be
>easier to use a little snippet of scriptlet here and there instead of
>making a round-about (albeit clever) and more verbose way of doing the
>same thing without scriptlets...
>
>any opinions is welcome! i want to be able to sleep without nightmares
>about this!! :)
>
>
>
>
>
>__________________________________
>Do you Yahoo!?
>Take Yahoo! Mail with you! Get it on your mobile phone.
>http://mobile.yahoo.com/maildemo
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by David Durham <da...@scott.af.mil>.
Craig McClanahan wrote:
> (1) Scriptlets, since they are Java code, require someone at least
> passably familiar with Java to change them later. If you have folks
> that are primarily page authors, you are faced with a cost of teaching
> them enough about Java syntax to make the code it needs to do, or
> having to involve two folks in every page (a page author and a Java
> developer), or paying Java developers to maintain HTML. None of those
> approaches is appealing to me.
In my personal opinion, a lot of these presentation layer technologies
can be more challenging to master than Java. For instance, I consider
myself to be proficient in Java, buy my CSS skills suck ass (pardon my
English). For others, their CSS is good, but their Java, eh, not so
good. Time invested in the particular technologies may explain the
discrepancies, still the strength of JSP Custom Tags comes into play:
they are a tool for collaboration among developers.
> (2) Scriptlets, since they are Java code, bind you to a particular
> representation of your data to a much higher degree than scripting
> expressions do. Take your favorite Struts action form, and implement
> it first as a DynaBean (because it's faster to prototype that way),
> and use tags like <html:text> when building your input forms. Now,
> lets say a requirement changes such that you have to do some
> specialized work when a form bean property is set or retrieved, such
> that you need to switch to a regular ActionForm implementation
> instead. If you used the Struts tags, how much did you have to change
> the JSP source? None -- the "name" and "property" expressions work
> with either dynabean action forms or POJO ones. On the other hand, if
> you used scriptlet expressions, you'd have to change every single one
> of them.
I don't think this is necessarily true. You could design your scriplets
to display from POJB (plain old JavaBeans(tm)) or dynabeans.
>(3) The custom tags do more for you than just set and retrieve data.
>Here's just a couple of examples where using the tag gets you extra
>benefits for free:
>
>
>
> * In order for sessions to work on browsers with cookies disabled,
> you have to call an extra method to encode them. <html:link> does
> it for you ... a dynamic scriptlet call does not.
This could be done with a scriptlet. Something like:
<%= getLink("link display", "link name", request) %>
Still, <html:link> is preferred.
> None of this is to say that you can't be productive when using
> scriptlets. But my experience has been that whatever boost they give
> you tends to be short term; over the long run, you're generally better
> off desigining for minimum maintenance, rather than designing for
> minimum initial development.
Quality scriptlet libraries are not exactly pervasive. Anyway, the tags
add an air of consistency to JSPs. I'm of the opinion that style is
important.
- Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Craig McClanahan <cr...@gmail.com>.
On Sat, 28 Aug 2004 11:47:14 +1200, Jason Lea <ja...@kumachan.net.nz> wrote:
> Tomcat 5 includes *"JSP Custom Tag Pooling* - The java objects
> instantiated for JSP Custom Tags can now be pooled and reused. This
> significantly boosts the performance of JSP pages which use custom tags."
>
This is true for "classic" tag handlers ... i.e. those that conform to
the JSP 1.1 or 1.2 APIs, but not for JSP 2.0 tag handlers.
> I seem to remember reading somewhere (can't remember where, does someone
> have a link) that JSPs that don't have scriptlets can have the taglib
> pooled. I assume this means the taglib is loaded and shared amongst
> each JSP that uses them, speeding up the page and reducing memory. I
> guess a scriplet on a page may make the web server make a local copy?
>
The pooling being discussed isn't related to the tag *classes* (which
would depend on where you put the JAR containing them -- tag classes
in common/lib or shared/lib are indeed shared), but the tag
*instances* themselves. In the early days of JSP (or, more properly,
in the days of the JVMs that were available in the early days of JSP)
object creation was more expensive than it is today, so there was a
desire to allow the same tag instance to be used if the same tag, with
the same set of defined attributes (although not necessarily the same
values) was used more than once. In practice, this didn't help much
-- especially now, when object creation is much cheaper -- and
complicated the design of tag classes because the author had to deal
with some extra restrictions.
For JSP 2.0's "SimpleTag" API, the tag handler developer does not have
to worry about instance reuse. You can do pretty much whatever you
need to and know that, when the JSP page is done with your tag, it'll
simply get garbage collected instead.
> I find with Tomcat 5+JSP 2.0 that writing pages with tags and EL has
> made them much easier to write and understand. With being able to get
> rid of <c:out /> tags and just use ${var} everywhere makes them much
> easier to read.
That's yet another advantage of getting used to the EL syntax ... in
JSP 2.0 you can use it everywhere, not just in attributes of tags that
undertsand it.
<p>Hello $name!</p>
> --
> Jason Lea
>
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Jason Lea <ja...@kumachan.net.nz>.
Tomcat 5 includes *"JSP Custom Tag Pooling* - The java objects
instantiated for JSP Custom Tags can now be pooled and reused. This
significantly boosts the performance of JSP pages which use custom tags."
I seem to remember reading somewhere (can't remember where, does someone
have a link) that JSPs that don't have scriptlets can have the taglib
pooled. I assume this means the taglib is loaded and shared amongst
each JSP that uses them, speeding up the page and reducing memory. I
guess a scriplet on a page may make the web server make a local copy?
I find with Tomcat 5+JSP 2.0 that writing pages with tags and EL has
made them much easier to write and understand. With being able to get
rid of <c:out /> tags and just use ${var} everywhere makes them much
easier to read.
--
Jason Lea
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Woodchuck <wo...@yahoo.com>.
--- Craig McClanahan <cr...@gmail.com> wrote:
> On Fri, 27 Aug 2004 10:21:58 -0700 (PDT), Woodchuck
> <wo...@yahoo.com> wrote:
> > sorry to bring this up on a Friday...
>
> Yah, I didn't know we could have serious discussions on Fridays any
> more :-).
Monday is just as bad i guess... nobody is serious on Mondays :)
>
> >
> > does everyone here have pure Struts/JSTL jsp pages that is
> absolutely
> > void of scriptlets?
>
> Except for some unit tests (where scriptlets are used to configure
> the
> initial conditions), yes.
>
> >
> > or do you have jsp pages that use a combination of Struts/JSTL and
> > scriptlets, all living together harmoniously using whichever method
> is
> > easiest/cleanest?
> >
> > is mixing Struts/JSTL with traditional scriptlets a bad thing?
> >
>
> It is too simplistic to say such a thing is "good" or "bad" on any
> absolute scale. As with every other design decision, you have to
> trade off the impacts of any particular decision on your overall
> goals
i guess it would have been too easy to be a black and white issue.
damn you, grey!! damn you!! lol
> -- and nearly every reasonable choice you might consider has some
> positive impacts and some negative impacts.
uh oh, don't get me started on my English teacher's "Everything is
Connected" philosophy... lol
>
> > i have to say that i would prefer to *not* mix scriptlets with
> > Struts/JSTL but in some situations it seems scriptlets is the
> better
> > solution (in terms of code maintainability). that is, it would be
> > easier to use a little snippet of scriptlet here and there instead
> of
> > making a round-about (albeit clever) and more verbose way of doing
> the
> > same thing without scriptlets...
> >
> > any opinions is welcome! i want to be able to sleep without
> nightmares
> > about this!! :)
>
> My reasoning for not using scriptlets is based around technical
> issues
> (see below), but they are fundmentally driven by an 80/20 rule I've
> observed that hasn't been articulated in this thread yet ... 80% of
> the investment you will make in the lifetime of the application wil
> be
> maintenance, versus 20% on the original development.
i had always thought the 80/20 rule was 80% design, 20% development..
but your version is true too! (maybe we can say your 80/20 is a
'top-down 80/20 rule' and the one i've always known is a 'bottom-up
80/20 rule') :)
> To the extent
> that this ratio is true, then, it behooves me to choose design
> approaches that minimize the long term cost of dealing with changes
> --
> and, as we all know, the only constant in life is that it's gonna
> change.
>
> Given this bias, then, my problem with scriptlets:
>
> (1) Scriptlets, since they are Java code, require someone at least
> passably familiar with Java to change them later. If you have folks
> that are primarily page authors, you are faced with a cost of
> teaching
> them enough about Java syntax to make the code it needs to do, or
> having to involve two folks in every page (a page author and a Java
> developer), or paying Java developers to maintain HTML. None of
> those
> approaches is appealing to me.
lol, tell that to my employers! <sobbing>i'm mr. one-man web app guy,
have to do HTML, javascript, css, java everything
(model,view,controller), jdbc, database design, build deployment (ant),
server admin (tomcat), vss (source control admin)...</sobbing>
<hears whip crackle coming.../>
>
> (2) Scriptlets, since they are Java code, bind you to a particular
> representation of your data to a much higher degree than scripting
> expressions do. Take your favorite Struts action form, and implement
> it first as a DynaBean (because it's faster to prototype that way),
> and use tags like <html:text> when building your input forms. Now,
> lets say a requirement changes such that you have to do some
> specialized work when a form bean property is set or retrieved, such
> that you need to switch to a regular ActionForm implementation
> instead. If you used the Struts tags, how much did you have to
> change
> the JSP source? None -- the "name" and "property" expressions work
> with either dynabean action forms or POJO ones. On the other hand,
> if
> you used scriptlet expressions, you'd have to change every single one
> of them.
great point.
>
> (3) The custom tags do more for you than just set and retrieve data.
> Here's just a couple of examples where using the tag gets you extra
> benefits for free:
>
> * In order for sessions to work on browsers with cookies disabled,
> you have to call an extra method to encode them. <html:link> does
> it for you ... a dynamic scriptlet call does not.
yea, that's true, i wouldn't want to have to manually maintain URL
rewriting.
>
> * In order to avoid cross site scripting attacks, you want to be
> careful
> about writing out dynamic content that was originally entered (on
> an
> input form) by users, where it might have "<" and ">" characters in
> it.
> The tags filter for you (unless you turn it off) -- naive calls to
> out.println() does not.
awesome point. i keep forgetting that tags are really a filter for
this sort of thing.
>
> (4) Scriptlets, since they are Java code, can do anything that Java
> can do. This creates the potential for developers to "cheat" and mix
> business logic and presentation logic together (in the JSP page) in
> ways that makes maintenance harder (i.e. more expensive) later. Yes,
> you can catch such things by having your architects and leads do
> aggressive code reviews, but I'd rather have my architects designing,
> and my leads managing the development, instead of policing for this
> sort of thing.
yea, that tends to happen. the more scriptlets there are the more
likely they will have some business logic creep into them.
>
> None of this is to say that you can't be productive when using
> scriptlets. But my experience has been that whatever boost they give
> you tends to be short term; over the long run, you're generally
> better
> off desigining for minimum maintenance, rather than designing for
> minimum initial development.
thanks, Craig. i see your point. tags development may cost a bit more
in the beginning but the benefits later on are well worth it!
>
> Craig
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Craig McClanahan <cr...@gmail.com>.
On Fri, 27 Aug 2004 10:21:58 -0700 (PDT), Woodchuck
<wo...@yahoo.com> wrote:
> sorry to bring this up on a Friday...
Yah, I didn't know we could have serious discussions on Fridays any more :-).
>
> does everyone here have pure Struts/JSTL jsp pages that is absolutely
> void of scriptlets?
Except for some unit tests (where scriptlets are used to configure the
initial conditions), yes.
>
> or do you have jsp pages that use a combination of Struts/JSTL and
> scriptlets, all living together harmoniously using whichever method is
> easiest/cleanest?
>
> is mixing Struts/JSTL with traditional scriptlets a bad thing?
>
It is too simplistic to say such a thing is "good" or "bad" on any
absolute scale. As with every other design decision, you have to
trade off the impacts of any particular decision on your overall goals
-- and nearly every reasonable choice you might consider has some
positive impacts and some negative impacts.
> i have to say that i would prefer to *not* mix scriptlets with
> Struts/JSTL but in some situations it seems scriptlets is the better
> solution (in terms of code maintainability). that is, it would be
> easier to use a little snippet of scriptlet here and there instead of
> making a round-about (albeit clever) and more verbose way of doing the
> same thing without scriptlets...
>
> any opinions is welcome! i want to be able to sleep without nightmares
> about this!! :)
My reasoning for not using scriptlets is based around technical issues
(see below), but they are fundmentally driven by an 80/20 rule I've
observed that hasn't been articulated in this thread yet ... 80% of
the investment you will make in the lifetime of the application wil be
maintenance, versus 20% on the original development. To the extent
that this ratio is true, then, it behooves me to choose design
approaches that minimize the long term cost of dealing with changes --
and, as we all know, the only constant in life is that it's gonna
change.
Given this bias, then, my problem with scriptlets:
(1) Scriptlets, since they are Java code, require someone at least
passably familiar with Java to change them later. If you have folks
that are primarily page authors, you are faced with a cost of teaching
them enough about Java syntax to make the code it needs to do, or
having to involve two folks in every page (a page author and a Java
developer), or paying Java developers to maintain HTML. None of those
approaches is appealing to me.
(2) Scriptlets, since they are Java code, bind you to a particular
representation of your data to a much higher degree than scripting
expressions do. Take your favorite Struts action form, and implement
it first as a DynaBean (because it's faster to prototype that way),
and use tags like <html:text> when building your input forms. Now,
lets say a requirement changes such that you have to do some
specialized work when a form bean property is set or retrieved, such
that you need to switch to a regular ActionForm implementation
instead. If you used the Struts tags, how much did you have to change
the JSP source? None -- the "name" and "property" expressions work
with either dynabean action forms or POJO ones. On the other hand, if
you used scriptlet expressions, you'd have to change every single one
of them.
(3) The custom tags do more for you than just set and retrieve data.
Here's just a couple of examples where using the tag gets you extra
benefits for free:
* In order for sessions to work on browsers with cookies disabled,
you have to call an extra method to encode them. <html:link> does
it for you ... a dynamic scriptlet call does not.
* In order to avoid cross site scripting attacks, you want to be careful
about writing out dynamic content that was originally entered (on an
input form) by users, where it might have "<" and ">" characters in it.
The tags filter for you (unless you turn it off) -- naive calls to
out.println() does not.
(4) Scriptlets, since they are Java code, can do anything that Java
can do. This creates the potential for developers to "cheat" and mix
business logic and presentation logic together (in the JSP page) in
ways that makes maintenance harder (i.e. more expensive) later. Yes,
you can catch such things by having your architects and leads do
aggressive code reviews, but I'd rather have my architects designing,
and my leads managing the development, instead of policing for this
sort of thing.
None of this is to say that you can't be productive when using
scriptlets. But my experience has been that whatever boost they give
you tends to be short term; over the long run, you're generally better
off desigining for minimum maintenance, rather than designing for
minimum initial development.
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Daniel Perry <d....@netcase.co.uk>.
One thing i would suggest, is that if you are working in a team, and you
wish to include these really simple one line scriptlets (like the example i
gave you), then put the scriptlets at the top of the jsp along with the "<%@
page" type declarations, taglib declarations, etc. It makes it easier for
the web design people.
"ignore the crap at the top of the page" and "dont touch any tags you dont
understand" seems to work as instructions for them :)
Daniel.
> -----Original Message-----
> From: Woodchuck [mailto:woodchuck_5@yahoo.com]
> Sent: 27 August 2004 18:48
> To: Struts Users Mailing List
> Subject: RE: philosophical question/poll about Struts/JSTL, scriptlets
>
>
>
> --- Daniel Perry <d....@netcase.co.uk> wrote:
>
> > hah forget the 'purist' approach!
> >
> > I use jstl / struts taglibs whereever possible.
> >
> > if i had a choice between writing my on taglib or scriptlet.... for
> > me
> > scriptlet wins - much less hassel, and the code is there for you on
> > the jsp,
> > and it's only normally for very simple things.
> >
> > The main times i use scriptlets are for stupidly simple things that
> > appear
> > to have been overlooked with el/jstl:
> >
> > <% pageContext.setAttribute("linefeed", "\n"); %>
> >
> > Because you cant use \n in el for search and replace strings.
> >
> > Other use is for copying static final variables to the page context
> > (how no
> > one spotted this before el was finalised i will never know? or am i
> > missing
> > somthing?)
>
> hehe, yea the lack of easy way to access static final variables using
> Struts/JSTL is what brought me to this state, lol.
>
> something so easy in scriptlets but needs quite a bit of coding to do
> in non-scriptlet form by comparison.
>
> >
> > Daniel.
> >
>
>
>
>
> _______________________________
> Do you Yahoo!?
> Win 1 of 4,000 free domain names from Yahoo! Enter now.
> http://promotions.yahoo.com/goldrush
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Woodchuck <wo...@yahoo.com>.
--- Daniel Perry <d....@netcase.co.uk> wrote:
> hah forget the 'purist' approach!
>
> I use jstl / struts taglibs whereever possible.
>
> if i had a choice between writing my on taglib or scriptlet.... for
> me
> scriptlet wins - much less hassel, and the code is there for you on
> the jsp,
> and it's only normally for very simple things.
>
> The main times i use scriptlets are for stupidly simple things that
> appear
> to have been overlooked with el/jstl:
>
> <% pageContext.setAttribute("linefeed", "\n"); %>
>
> Because you cant use \n in el for search and replace strings.
>
> Other use is for copying static final variables to the page context
> (how no
> one spotted this before el was finalised i will never know? or am i
> missing
> somthing?)
hehe, yea the lack of easy way to access static final variables using
Struts/JSTL is what brought me to this state, lol.
something so easy in scriptlets but needs quite a bit of coding to do
in non-scriptlet form by comparison.
>
> Daniel.
>
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: philosophical question/poll about Struts/JSTL, scriptlets
Posted by Daniel Perry <d....@netcase.co.uk>.
hah forget the 'purist' approach!
I use jstl / struts taglibs whereever possible.
if i had a choice between writing my on taglib or scriptlet.... for me
scriptlet wins - much less hassel, and the code is there for you on the jsp,
and it's only normally for very simple things.
The main times i use scriptlets are for stupidly simple things that appear
to have been overlooked with el/jstl:
<% pageContext.setAttribute("linefeed", "\n"); %>
Because you cant use \n in el for search and replace strings.
Other use is for copying static final variables to the page context (how no
one spotted this before el was finalised i will never know? or am i missing
somthing?)
Daniel.
> -----Original Message-----
> From: Woodchuck [mailto:woodchuck_5@yahoo.com]
> Sent: 27 August 2004 18:22
> To: struts
> Subject: philosophical question/poll about Struts/JSTL, scriptlets
>
>
> sorry to bring this up on a Friday...
>
> does everyone here have pure Struts/JSTL jsp pages that is absolutely
> void of scriptlets?
>
> or do you have jsp pages that use a combination of Struts/JSTL and
> scriptlets, all living together harmoniously using whichever method is
> easiest/cleanest?
>
> is mixing Struts/JSTL with traditional scriptlets a bad thing?
>
> i have to say that i would prefer to *not* mix scriptlets with
> Struts/JSTL but in some situations it seems scriptlets is the better
> solution (in terms of code maintainability). that is, it would be
> easier to use a little snippet of scriptlet here and there instead of
> making a round-about (albeit clever) and more verbose way of doing the
> same thing without scriptlets...
>
> any opinions is welcome! i want to be able to sleep without nightmares
> about this!! :)
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
> http://mobile.yahoo.com/maildemo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org