You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Joerg Erdmenger <jo...@woerd.com> on 2001/05/02 16:52:09 UTC
Example Servlet not using VelocityServlet
Hi,
is there and can somebody point me to an example of how to write a Servlet
using velocity without using extending the VelocityServlet class (in a
similar way as the WebMacro Example in Jason Hunters 'Java Servlet
Programming' book).
Or is this a very bad idea anyway?
Any help and suggestions are welcome (and please don't make it overly
complicated as I am relatively new to Java/Servlets ;-)
Joerg
Re: Example Servlet not using VelocityServlet
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Keng Wong wrote:
>
> I have taken a look at VelocityServlet. It does provide me with a cleaner
> way of abstraction and for me to build a template. I saw that the
> doRequest() is a private method. SHould I extend handleRequest() for
> redirections (servlet redirection occurs when a specific event happens, thus
> avoiding unnecessary template processing) ?\
In velocity 1.1, there is a new method
Template handleRequest( HttpServletRequest, HttpServletResponse,
Context)
in which you can return null, and no template processing happens.
Further, doRequest() is now protected, not private.
geir
> Thanks.
>
> -keng
>
> > -----Original Message-----
> > From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
> > Behalf Of Geir Magnusson Jr.
> > Sent: Wednesday, May 02, 2001 9:07 AM
> > To: velocity-user@jakarta.apache.org
> > Subject: Re: Example Servlet not using VelocityServlet
> >
> >
> > Velocity and WebMacro are very similar in how they work - you should be
> > able to just follow that example.
> >
> > However, I would think that you want to extend VelocityServet - it does
> > many nice things for you w/o any real loss of generality.
> >
> > You can participate in all parts of the request processing, from setting
> > up the context to post rendering cleanup.
> >
> > I would take a good look at that - it's something we support, and many
> > others use it.
> >
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
RE: Example Servlet not using VelocityServlet
Posted by Keng Wong <ke...@verizon.net>.
I have taken a look at VelocityServlet. It does provide me with a cleaner
way of abstraction and for me to build a template. I saw that the
doRequest() is a private method. SHould I extend handleRequest() for
redirections (servlet redirection occurs when a specific event happens, thus
avoiding unnecessary template processing) ?
Thanks.
-keng
> -----Original Message-----
> From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
> Behalf Of Geir Magnusson Jr.
> Sent: Wednesday, May 02, 2001 9:07 AM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Example Servlet not using VelocityServlet
>
>
> Velocity and WebMacro are very similar in how they work - you should be
> able to just follow that example.
>
> However, I would think that you want to extend VelocityServet - it does
> many nice things for you w/o any real loss of generality.
>
> You can participate in all parts of the request processing, from setting
> up the context to post rendering cleanup.
>
> I would take a good look at that - it's something we support, and many
> others use it.
>
Re: Example Servlet not using VelocityServlet
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Joerg Erdmenger wrote:
>
> Hi,
>
> is there and can somebody point me to an example of how to write a Servlet
> using velocity without using extending the VelocityServlet class (in a
> similar way as the WebMacro Example in Jason Hunters 'Java Servlet
> Programming' book).
> Or is this a very bad idea anyway?
Velocity and WebMacro are very similar in how they work - you should be
able to just follow that example.
However, I would think that you want to extend VelocityServet - it does
many nice things for you w/o any real loss of generality.
You can participate in all parts of the request processing, from setting
up the context to post rendering cleanup.
I would take a good look at that - it's something we support, and many
others use it.
>
> Any help and suggestions are welcome (and please don't make it overly
> complicated as I am relatively new to Java/Servlets ;-)
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/