velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <>
Subject Re: VelocityViewServlet
Date Thu, 18 Aug 2005 03:08:14 GMT
On 8/17/05, <> wrote:
> Hi people,
> I've built quite a large web app using the VelocityServlet. I know this is
> now somewhat deprecated ( I didn't know this before I built the app). I
> was wondering if there was a decent tutorial on converting existing apps
> to VelocityViewServlet.

hmm.  i can't think of any tutorials on the subject.  but depending
somewhat on the nature of your application, it shouldn't be difficult.
 the two servlets are quite similar.  in fact, the VelocityViewServlet
is pretty much the VelocityServlet plus some cool stuff.  nothing was
really taken away except perhaps a few bugs.

i'd be willing to help you troubleshoot during the conversion, but
only on the lists, so others will hopefully chime in with help and
other/later users can read about it.

the first question to ask is "do you extend the VelocityServlet? and
if so, what do you override?"  the next would be "do you use the $req
and $res objects much in your templates?"  (those are changed to
$request and $response in the VVS.)

> Also what benefits will the VelocityViewServlet bring over the
> VelocityServlet?

lots!  some major bug-fixes, the WebappLoader, toolbox support,
ChainedContext, and more.  it's easier to get started with and will
take you further faster.  the WebappLoader is much more webapp
friendly than the FileResourceLoader.  toolbox support allows you to
create a consistent and powerful interface(s) for you to use during
template design, and makes it easy to take advantage of many
ready-made tools.  the ChainedContext automatically exposes your
request, session, and servlet context attributes to eliminate the need
for #set( $foo = $req.getAttribute("foo") ) statements throughout your

and if you want to go even further, you might look into the
VelocityLayoutServlet. it extends the VVS to improve error handling
and allow you to easily and flexibly use layouts to simplify and
consistify your templates.

> I've noticed that over slow connections that template pages rendered with
> velocity sometimes appears in chunks when the same page done as a jsp page
> doesn't. Does the VelocityServlet use a BufferedWriter or is this
> something that is new in VelocityViewServlet?

i'm not sure i understand the question.  but here's what i know of the
two servlet's writers...

the VelocityServlet uses a VelocityWriter to wrap an
OutputStreamWriter which wraps the result of
response.getOutputStream().  these VelocityWriters are pooled and
recycled for new requests.

the VelocityViewServlet similarly uses and pools VelocityWriters, but
by default it will use them to wrap the result of
response.getWriter().  This allows velocity templates to be intermixed
with JSPs or other view tiers in a single request (using something
like the Tiles or the ImportTool).

does that help?

> Thanks
> Andrew
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message