You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Philipp Leusmann <ph...@post.rwth-aachen.de> on 2002/11/05 19:25:33 UTC

Velocity vs. Servlets

Hi,

I am currently in the process of beginning to write a web-application. Since
the design has to be customizable I would like to use Velocity as a template
engine.
But what is not quite clear to me, yet, is the way how servlets using
velocity compare to servlets written usings Sun´s Servlet API.
Will I have to write everything in the Sun-servlet-style and only use
subclasses of VelocityServlet instead of subclasses of HTTPServlet and the
rest stays the same (for example Listeners etc)? Or will I have to go a
completely different way?

Hope you can answer my question,
 Philipp



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocity vs. Servlets

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
The VelocityViewServlet in the tools subproject is also very helpful.
You write regular servlets but the view layer is all velocity pages:
"page.vm".  In web.xml you map *.vm -> VelocityViewServlet.  All of
your requests are processed as usual, then handed off to the VVS
which examines your request and session object (possibly more) and
makes all the values accessible by velocity templates.

http://jakarta.apache.org/velocity/toolsubproject.html

Its worth checking out, I think its a great product.

Charlie

> -----Original Message-----
> From: Philipp Leusmann [mailto:philipp.leusmann@post.rwth-aachen.de]
> Sent: Tuesday, November 05, 2002 1:26 PM
> To: velocity-user@jakarta.apache.org
> Subject: Velocity vs. Servlets
>
>
> Hi,
>
> I am currently in the process of beginning to write a
> web-application. Since
> the design has to be customizable I would like to use Velocity as
> a template
> engine.
> But what is not quite clear to me, yet, is the way how servlets using
> velocity compare to servlets written usings Sun´s Servlet API.
> Will I have to write everything in the Sun-servlet-style and only use
> subclasses of VelocityServlet instead of subclasses of HTTPServlet and the
> rest stays the same (for example Listeners etc)? Or will I have to go a
> completely different way?
>
> Hope you can answer my question,
>  Philipp
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity vs. Servlets

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 11/5/02 1:25 PM, "Philipp Leusmann"
<ph...@post.rwth-aachen.de> wrote:

> Hi,
> 
> I am currently in the process of beginning to write a web-application. Since
> the design has to be customizable I would like to use Velocity as a template
> engine.
> But what is not quite clear to me, yet, is the way how servlets using
> velocity compare to servlets written usings Sun´s Servlet API.

You would still use Sun's Servlet API.

Velocity offers an example servlet 'VelocityServlet' which is derived from
HTTPServlet - to everything is the servlet API.

You don't have to use the VelocityServlet - it's offered for your
convenience.  Most people use it though.

> Will I have to write everything in the Sun-servlet-style and only use
> subclasses of VelocityServlet instead of subclasses of HTTPServlet and the
> rest stays the same (for example Listeners etc)? Or will I have to go a
> completely different way?

You can use your own servlets and just use Velocity - I do that in many
projects where I don't want to use the response handling model of the
VelocityServlet. (For most of the things I do, I find that model
inappropriate).

Rather, my base class takes care of all the config of the velocity engine,
and I just use it in the methods in my servlet.

Remember - Velocity itself is agnostic to the system in which you use it (as
long as it's Java :).  So use the example Velocity servlet for convenience,
or if you have other needs that doesn't fit, roll your own and just use the
Velocity engine.

Geir
 
> Hope you can answer my question,
> Philipp
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr. 
geirm@adeptra.com                                    +1-203-355-2219 (w)
Adeptra Inc.                                         +1-203-247-1713 (m)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>