On Sun, Aug 26, 2001 at 10:44:34PM -0400, Geir Magnusson Jr. wrote:
>
> > My initial impressions are good, my only complaint was that I had to build
> > it and an unfamiliarity with tag libraries.
> 
> Come on. :)  Because of JJAR, the only thing you had to do was download
> from CVS, have ant installed, and type
> 
> $ ant getjars
> $ ant jar
> 
> and done.
> 
> I am not that familiar with taglibs either :)

I'm lazy.  ;-)  The existing documentation is very well written, I don't
think there's any way it could be better.

> > I wrote a couple simple pages, one in JSP, one using JSP/Velocity and
> > performance was pretty good, maybe a 30% performance hit.
> 
> Really?  I am surprised that JSP is that much slower :)
> 
> Seriously, what JSP engine?  Velocity, with a decent data-access page, I
> believe will easily keep up with JSP.

Tomcat 3.2.3.  From what I understand, the tablib parsing routines in Tomcat
3.2.X are really quite slow.  The two simple pages I tested are simple:
Create an array of strings 10 long, iterate though the array printing out
each element and printing the current date.

> > So are my questions:
> > 
> > How does the taglib work? 
> 
> Very simply - it treats everying in between the start and end tags as
> VTL  and parses and renders it into the output stream.
> 
> > How does velocity get invoked to parse the code?
> 
> The taglib uses the standard taglib callback architecture - nothing
> special or magical.

Cool.

> > Where is the velocity engine hiding? 
> 
> In the normal place - the velocity.jar that is hopefully not in your
> classpath, but in WEB-INF/lib

This actually introduced another issue:  I had a servlet in the same context
which also uses velocity (I map *.vm to this servlet).  If I loaded one of
the JSPs first, it didn't initialize velocity as I expected.  If I made sure
that my servlet initialized first (and initialized Velocity) then both would
work since the taglib doesn't depending on any files in the filesystem.

> > I know you mention velocimacros as a
> > benefit to using the taglib, is there an equivalent to the VM_globals.vm or
> > do you just have to include a global file which has your macros defined
> > there?
> 
> (You really can't include VMs.)
> 
> Yes, a global library (or plural...)  will indeed work if you use the
> singleton model for Velocity (which the taglibs does).  What you could
> do is make a little startup servlet (use <load-on-startup>) that
> configures Velocity with the template path to find the global library
> for your webapp.
> 
> I will try to document how to do that this week.

(I should have more closely read this last paragraph before writing my last
one)  Looks like I already  figured this part out.  ;-)

Here's a couple more performance notes (which have caused me to lose
interest in the Velocity taglib for now):

For the simple page I was testing with (my home page
http://www.greenhydrant.com/~drees/, mostly static pages with a header,
footer included), I found that JSP or JSP/Velocity is a LOT slower than
mapping *.vm to a controller servlet (MVC type app).

Probably about twice as slow, I was getting ~30 hits/s with JSP or
JSP/Velocity, but about twice as many using a servlet/Velocity with some
quick testing to Apache's ab.

Under other servlet engines I don't expect the performance penalty to be as
high, but I think it's probably just Velocity being too fast for it's own
good when run under normal conditions.  ;-)

-Dave

Reply via email to