Re: [OT] RE: How to get the tag name from within a taglib class ?

2020-09-16 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Cris,

On 9/15/20 13:18, Berneburg, Cris J. - US wrote:
> CS> IMO, the JSP effort was a stepping-stone on a path to better
> CS> technologies like Velocity, FreeMarker, and others. If I were
> CS> king, JSP would just go away. Just my POV of course [...]
>
> cjb> what do you like better about Velocity, FreeMarker, etc. cjb>
> more than JSP?
>
> CS> I started using Velocity years ago [...] It definitely has its
> CS> warts but it's relatively actively maintained, and anything I
> CS> need I can get in and do myself, submit patches, etc. CS> CS>
> Advantages over JSP (IMHO): CS> CS> - Can't execute direct Java
> code, ever CS> - Non-verbose syntax CS> - No limit on template
> length [...] CS> - Easy to install POJO "tools" which just expose
> Java objects CS>   to the runtime so you can $tool.doSomething()
> [...] CS> - Can load templates from anywhere (disk, DB, URL, etc.)
>
> Good to know!  I also see that it is an ASF project.
>
> Is Velocity interpreted or compiled like JSP?  I'm thinking of
> performance impacts, like during loops.
>
> Answering my own question, the Velocity FAQ says, "Velocity
> doesn't compile your templates. They are parsed into an AST
> (abstract syntax tree) and that is what gets cached."
Right. It's not really interpreted OR compiled. But it's not re-parsed
on every request unless you configure it to do that. I've never had
any performance complaints myself.

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl9ip94ACgkQHPApP6U8
pFhooxAAifqd19yhLdxBAdDJY1ttX0CWB3/F3PUZ0qf6NoHU/kN7tLi5oejQpJ2a
YTeml+vO/jI/c6sF5A/6rPdKyx6rjiUercUFP6efMJH6z4zVitgGfshWiAwWiBur
SkDGtWsFUnco1fFOcSB2mD42amOl6JVEmpUyjMdlBw3wxjUY+fofKLD5/H1u2gb0
IqBmpZr7gPnhOK03Iti2zdaUCAf+iAJ+rgjnuo/iXpDRIa2s3JFxdbY0192id5sv
bMPzO4hwU7aaR7qARXY+LBMFrJyuh2ICfIaz9s5uR+S20fSipcGkVSDl9OqATEls
pHM/ff8d7fLuozj6JgVR1jDfQLOHEYwMktgJ9I1Lst4C+FaHsWoShm0mailYxHf6
FvF/XCaCxQ1mgwslnbfXBV65tU6okOMnkmZDCG8otxT/KMyhTgtSyfj80ft2x4Tq
0IvPWm8ztwj3Tr/P7Vg2T4RX46ESHQ20i0CtcGtMaaWRlVdTcBRYSR/JRsa+Hrdq
W0SJ2PTO7stjuPDYTSog/wrprwS2QwKrpkj7RVgVXsOUShHTV9aswIWZjW+jiJyA
3DlsmBMeXhLdrlMTw8i1/fvHa+TtPjHoFvSH6sAHs3xX+QbLV3+bJ6/Z3+BU0V3N
H76kobuPTXwEZXJ4y5TgY4Q8Jj/NQDwbnL+Si1Ut+gCpNlaD+B8=
=O8Ce
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: [OT] RE: How to get the tag name from within a taglib class ?

2020-09-15 Thread Berneburg, Cris J. - US
Thanks Chris!

CS> IMO, the JSP effort was a stepping-stone on a path to better
CS> technologies like Velocity, FreeMarker, and others. If I were
CS> king, JSP would just go away. Just my POV of course [...]

cjb> what do you like better about Velocity, FreeMarker, etc.
cjb> more than JSP?

CS> I started using Velocity years ago [...] It definitely has its
CS> warts but it's relatively actively maintained, and anything I
CS> need I can get in and do myself, submit patches, etc.
CS>
CS> Advantages over JSP (IMHO):
CS>
CS> - Can't execute direct Java code, ever
CS> - Non-verbose syntax
CS> - No limit on template length [...]
CS> - Easy to install POJO "tools" which just expose Java objects
CS>   to the runtime so you can $tool.doSomething() [...]
CS> - Can load templates from anywhere (disk, DB, URL, etc.)

Good to know!  I also see that it is an ASF project.

Is Velocity interpreted or compiled like JSP?  I'm thinking of performance 
impacts, like during loops.

Answering my own question, the Velocity FAQ says, "Velocity doesn't compile 
your templates. They are parsed into an AST (abstract syntax tree) and that is 
what gets cached."

--
Cris Berneburg
CACI Senior Software Engineer




This electronic message contains information from CACI International Inc or 
subsidiary companies, which may be company sensitive, proprietary, privileged 
or otherwise protected from disclosure. The information is intended to be used 
solely by the recipient(s) named above. If you are not an intended recipient, 
be aware that any review, disclosure, copying, distribution or use of this 
transmission or its contents is prohibited. If you have received this 
transmission in error, please notify the sender immediately.


Re: [OT] RE: How to get the tag name from within a taglib class ?

2020-09-15 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Cris,

On 9/14/20 15:04, Berneburg, Cris J. - US wrote:
> Hey Chris
>
> CS> IMO, the JSP effort was a stepping-stone on a path to better
> CS> technologies like Velocity, FreeMarker, and others. If I were
> CS> king, JSP would just go away. Just my POV of course, you are
> CS> welcome to fall in love with JSP. :)
>
> Seeing as I am ever on the trailing edge of learning new or even
> dated technologies, what do you like better about Velocity,
> FreeMarker, etc. more than JSP?

I started using Velocity years ago because it was bundled with Turbine
which was being used by a project I got pulled-into. We eventually
ripped everything else out, but Velocity survived.

I looked at FreeMarker when doing a book review for Apache Struts 2
and it looked very interesting, but I discovered that the guy running
the project was ... difficult to work with. SO I've stuck with
Velocity for a long time.

It definitely has its warts but it's relatively actively maintained,
and anything I need I can get in and do myself, submit patches, etc.

Advantages over JSP (IMHO):

- - Can't execute direct Java code, ever
- - Non-verbose syntax
- - No limit on template length (JSP eventually hits the "Method too
long" problem which is very inconvenient)
- - Easy to install POJO "tools" which just expose Java objects to the
runtime so you can $tool.doSomething() and it'll do whatever that is,
converting the result to a String and dropping it into the output
- - Can load templates from anywhere (disk, DB, URL, etc.)

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl9gyksACgkQHPApP6U8
pFi2og//TI//2oxfo4iE3q0B1f4sMN8fT8K9EVT89EME1jfUHontVRXtrX+tke2f
t/3Os9veBJROAO5jOJvBCkefq7V2Lqij2289Vc7qVuuap+UqO/a+UCyOjxmVAHGh
TrMeuxRLV8V1GPhDo0pftoJEWXg6SnDEqo7TF/1kGAmcaHEkWUEYrOPLfE92GbHJ
8bNySZFEleXX3decZj1mBdAoL+SMV7jbSvONGrMDds0saAddUmYMpdP9VPnCnKfG
YS5Ec1Hx/1hshUisC1qOuarNCXH+84MLV98yM1pECoYCzx+2rTZ9RdoLwDnHjJB2
wJrc66P0yHOXyBfMamfpaxsUvTj2PON6RwBcbC7gaDMLIefGWM8TUROXMf7Odd40
TDZ+uJvyZBApeCnHkKrY/ipEvT4qb5sF0pVZTV9N6EBfqhKwBXgNqxTpCnAOkYFq
egXYO1JGShxCdnHfAgNHyMoZ61PLltwe5msW6ZTlAqex3teZkmIrVfXXINy/JEbs
lcRxe/V1EPBk9JxPJMy+hgDx4RBk6/ocepJbT2BR8nA9R1LBvA5h7wMr9iQw091S
pbBr7xuKnIncMuCqTTyjiPZV/+7fBRYZgGAqZX+2pNGJkZ+kNMm3FAPqz9pjw/LD
2DZyK7gqXmFCWGGdlWxLfPOpNb6ajv3slc3fMXxvdBNNpW1AYg8=
=AwcX
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



[OT] RE: How to get the tag name from within a taglib class ?

2020-09-14 Thread Berneburg, Cris J. - US
Hey Chris

CS> IMO, the JSP effort was a stepping-stone on a path to better
CS> technologies like Velocity, FreeMarker, and others. If I were
CS> king, JSP would just go away. Just my POV of course, you are
CS> welcome to fall in love with JSP. :)

Seeing as I am ever on the trailing edge of learning new or even dated 
technologies, what do you like better about Velocity, FreeMarker, etc. more 
than JSP?

--
Cris "NOT Trying to Start a Flame War" Berneburg
CACI Senior Software Engineer




This electronic message contains information from CACI International Inc or 
subsidiary companies, which may be company sensitive, proprietary, privileged 
or otherwise protected from disclosure. The information is intended to be used 
solely by the recipient(s) named above. If you are not an intended recipient, 
be aware that any review, disclosure, copying, distribution or use of this 
transmission or its contents is prohibited. If you have received this 
transmission in error, please notify the sender immediately.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: How to get the tag name from within a taglib class ?

2020-09-14 Thread Berneburg, Cris J. - US
Rony

RF> If possible I would like to write a single tagclass, but use it
RF> for two or more different tags, as the implementation would share
RF> quite a lot of code. Besides, it might be helpful for debugging.

CS> Feel free to build a base class with the shared code and then implement
CS> the differences in subclasses.

Sure, implementing a sub-class of TagSupport that acts as a custom tag 
super-class works fine.

RF> I would have a need to find out the tag name
RF> that caused the tagclass to run.
RF>
RF> Is this possible? If so, how would one be able to get at
RF> that tag name (any brief hints would suffice) ?

Not sure exactly what you mean...

Here's an example:

- CustomTagImplementation.java contains:
public class CustomTagImplementation extends TagSupport

- tags.tld contains:

CustomTag1
tags.CustomTagImplementation


CustomTag2
tags.CustomTagImplementation


- page.jsp contains:




Are either of these what you mean?

A. Get surrounding tag "" - TagSupport/CustomTagImplementation/getParent(), 
for calculating something like an xpath?

B. Get tag definition name "CustomTag1" - Ouch.  Sorry, no help there.  How 
about an intellectual exercise to kill some time?  :-)

Suppose you had a map of classes and associated tag names from either parsing 
tags.tld directly or exposing whatever structure holds classes instantiated 
from it.  You might still have a lookup problem due to a one-to-many 
relationship.  Using CustomTagImplementation/getClassName() as the map lookup 
key would have 2 theoretical answers, both "CustomTag1" and "CustomTag2".

By the time the page code is executed, the JSP has aleady been compiled.  
Looking at pre-compiled org/apache/jsp/page_jsp.java, each call to 
 gets its own _jspx_meth_* method.  There is a comment in 
each method, "//  tags:CustomTag1".  Seems kinda messy in there, and 
potentially fragile to depend on the pre-compiler output format.

It's too bad TagSupport is not auto-magically fed as a parameter the name of 
tag definition in the page that "called" it.  All in the engine, no changes to 
JSP pages.

While I have not used it myself, have you looked at SimpleTagSupport to see if 
it has something useful?

--
Cris Berneburg
CACI Senior Software Engineer




This electronic message contains information from CACI International Inc or 
subsidiary companies, which may be company sensitive, proprietary, privileged 
or otherwise protected from disclosure. The information is intended to be used 
solely by the recipient(s) named above. If you are not an intended recipient, 
be aware that any review, disclosure, copying, distribution or use of this 
transmission or its contents is prohibited. If you have received this 
transmission in error, please notify the sender immediately.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: How to get the tag name from within a taglib class ?

2020-09-13 Thread Rony G. Flatscher (Apache)
Hi Chris,

On 11.09.2020 19:31, Christopher Schultz wrote:
> > P.S.: If possible I would like to write a single tagclass, but use
> > it for two or more different tags, as the implementation would
> > share quite a lot of code. Besides, it might be helpful for
> > debugging.
>
> It seems like this is the wrong approach, unless you just want to use
> this for something like logging.

Not logging, but support for scripting languages.

> I you want the tags to behave differently, then you should have
> separate tag implementations. 

In this case the only difference would be that in one case ("script", 
"scriptlet") a return value
gets ignored, in the other case ("expression") the return value is used to 
print its string value to
the JSPWriter ("out").

> Feel free to build a base class with the shared code and then implement the 
> differences in subclasses.
Yes, if there is no easy way to learn about the tag that the tagclass got 
invoked for, which seems
to be the case here.
> It's been a lng time since I wrote a custom tag library but I do
> remember that the whole process was very painful and despite the
> flexibility allowed by the API, lots of common things (like getting
> the tag name!) were either awkward or impossible.

Well, it is not really "painful", just a lot of power, many roads that could be 
chosen and
flexibility at hand which at times is overwhelming for a newbie in this corner, 
hence my brief
question. :)

> IMO, the JSP effort was a stepping-stone on a path to better
> technologies like Velocity, FreeMarker, and others. If I were king,
> JSP would just go away. Just my POV of course, you are welcome to fall
> in love with JSP. :)

This assumes that the JSPs get written in Java only and one is ready to take on 
the learning curves
for additional frameworks.

In this case the aim is to allow scripting languages either via Apache BSF [1] 
(like Groovy
implemented in Java, ooRexx implemented in C++) or via the Java scripting 
framework [2] ("JSR-223"
[3], "javax.script") to be used for writing JSPs. This may not be 
attractive/interesting for
Java-savvy programmers who would create their server pages in Java, but it is 
*very* attractive,
even important for non-Java programmers who know one of the supported scripting 
languages.

In the end it should be easy to use Tomcat as the (Java-implemented) web server 
for web applications
that get implemented in other programming languages. Very much like the Apache 
web server [4] which
is written in C and allows other programming languages to exploit it.

---rony

P.S.: Maybe I should come up with a brief posting that tries to explain why it 
is important to
support non-Java programming languages in JSPs by default (and if 
interestesting to the Tomcat
community I can offer the code under AL, once it is done). Not sure whether all 
in the Tomcat
community know that Apache BSF ("Bean Scripting Framework") was created 
originally to allow
scripting languages to be used in JSPs! Hence I was very surprised to learn 
that scripting languages
are not supported in Tomcat by default.

[1] "Apache Bean Scripting Framework (BSF)": 


[2] Java package "javax.script" ("JSR-223"):


[3] "JSR-223", the "Java specification request 223":
 or


[4] "Apache Web Server", "Apache HTTP Server Project": 








Re: How to get the tag name from within a taglib class ?

2020-09-11 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Rony,

On 9/11/20 10:28, Rony G. Flatscher (Apache) wrote:
> While exploring, experimenting with creating a taglib (implementing
> the BodyTag interface) I would have a need to find out the tag name
> that caused the tagclass to run.
>
> Is this possible? If so, how would one be able to get at that tag
> name (any brief hints would suffice) ?
>
> ---rony
>
> P.S.: If possible I would like to write a single tagclass, but use
> it for two or more different tags, as the implementation would
> share quite a lot of code. Besides, it might be helpful for
> debugging.

It seems like this is the wrong approach, unless you just want to use
this for something like logging.

I you want the tags to behave differently, then you should have
separate tag implementations. Feel free to build a base class with the
shared code and then implement the differences in subclasses.

It's been a lng time since I wrote a custom tag library but I do
remember that the whole process was very painful and despite the
flexibility allowed by the API, lots of common things (like getting
the tag name!) were either awkward or impossible.

IMO, the JSP effort was a stepping-stone on a path to better
technologies like Velocity, FreeMarker, and others. If I were king,
JSP would just go away. Just my POV of course, you are welcome to fall
in love with JSP. :)

- -chris
-BEGIN PGP SIGNATURE-
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl9btG8ACgkQHPApP6U8
pFiYyhAAxG/8tTbGEp9pN3RvxjvRQXf+UupG4S3CXQNoNeVr4ffpWWii0kLHLLpj
YoBpqNUjsl4Uki2jLADPioUHKdLOmVSlL6NTEcgMyEdIrCsI1A49okpnAIIX5EVB
SRbfiUnv+37zQrKn3HbNnW8p6OoANHaEpGyfP6ylv6nj85nm9eAmXeKy/BcQLrI3
qRPD4migbvxGSU5M36YbT74q4azYV0bXEDh/9M3+Ky6iuPGGe0H+Y6V/JoERQt6d
X3+QFxNWPxWW/BEoWkNjKfLHJgbYWQC5mgk7kK3u82DUV6fqGE95tiimhmSQwz8t
qfeS/nDVVCh2c2hARneHriD8LV7ve62gjfY0y6BfXJG8Jl0vg6kokgdGu9hABLDG
bj/BYjznC8qipN2I/X7Rn5eEr7RzxmMN3WigOFjsh4fUWNzcT6EP2CIphnmifPFx
gIwj7SPuWmB8itN2MV4EouF+MkEB9LSPQGeDxYn+hTnfucbVjlH9QVJ5vQDGyGkr
ZbmMB7HdriDj1CRWO22y2sxGHkKjRTb/uzkfy0XDNCJpw1SswaVcm9lep+aVq1zc
ocKGS8PTbFiSKGLHt+ythKqTcwWhFjStXgGxPVntw/aBzlfIfIUlA8bsteWAH6Ic
Go27fA6u0bBp+afq6gYbkTtGSY/leaFi1xfwX0G5uAT/AAVdObc=
=2h8G
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



How to get the tag name from within a taglib class ?

2020-09-11 Thread Rony G. Flatscher (Apache)
While exploring, experimenting with creating a taglib (implementing the BodyTag 
interface) I would
have a need to find out the tag name that caused the tagclass to run.

Is this possible? If so, how would one be able to get at that tag name (any 
brief hints would suffice) ?

---rony

P.S.: If possible I would like to write a single tagclass, but use it for two 
or more different
tags, as the implementation would share quite a lot of code. Besides, it might 
be helpful for debugging.




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org