You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Paul Goepfert <pa...@gmail.com> on 2005/06/20 03:08:24 UTC

Have a question about intergrating a Velocity servlet into my velocity/struts app

I have written a servlet that extends from VelocityServlet. I am not
sure how to intergrate it into my velocity/struts app.  As of now all
my actions such as moving from page to page are handled by struts
using the VelStruts tool, $link.setAction().  I have been reading up
on velocity from a book called "Mastering Apache Veloicty".  The book
helped me out a lot.  The only thing that I noticed was that there was
no reference to a struts/velocity web app.  I also bought a book on
struts.  In that book there is a paragraph on velocity but nothing to
show me how to utlize struts/velocity together.

Would someone please show me a way to intergrate my new class into my
struts app.  I should tell you that I have overwritten the
handleRequest method in VelocityServlet.


-Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Have a question about intergrating a Velocity servlet into my velocity/struts app

Posted by Paul Goepfert <pa...@gmail.com>.
In my web app I do utlize the VelocityViewServlet.  I use that class
in my web.xml file as
to where all .vm filews should be mapped to.  I have been using the
VelocityStruts tools to create my velocity templates.  All my pages
work fine.  Well except for one.  The one page that needs data that I
collected from other pages within my web app can not output the
context that I created.

I will put the details about my problem in a seperate thread.


-Paul 
On 6/20/05, Simon Christian <si...@stoutstick.com> wrote:
> Hi Paul,
> 
> The VelocityServlet is all but deprecated now, with the recommended
> starting point being the VelocityViewServlet/VelocityLayoutServlet instead.
> 
> I'd strongly suggest you look at the whole of the VelocityStruts
> sub-project (http://jakarta.apache.org/velocity/tools/struts/) which
> uses the VelocityViewServlet for processing of templates. This includes
> some pretty good documentation showing you how to get started.
> 
> In very basic terms, you populate the (request) context within your
> Struts actions, and then forward the request to a Velocity template
> which is processed by the VelocityViewServlet to print your output to
> the client. Note that Struts need have no idea that Velocity is being
> used for the View.
> 
> - s
> 
> 
> Paul Goepfert wrote:
> > I have written a servlet that extends from VelocityServlet. I am not
> > sure how to intergrate it into my velocity/struts app.  As of now all
> > my actions such as moving from page to page are handled by struts
> > using the VelStruts tool, $link.setAction().  I have been reading up
> > on velocity from a book called "Mastering Apache Veloicty".  The book
> > helped me out a lot.  The only thing that I noticed was that there was
> > no reference to a struts/velocity web app.  I also bought a book on
> > struts.  In that book there is a paragraph on velocity but nothing to
> > show me how to utlize struts/velocity together.
> >
> > Would someone please show me a way to intergrate my new class into my
> > struts app.  I should tell you that I have overwritten the
> > handleRequest method in VelocityServlet.
> >
> >
> > -Paul
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Have a question about intergrating a Velocity servlet into my velocity/struts app

Posted by Simon Christian <si...@stoutstick.com>.
Hi Paul,

The VelocityServlet is all but deprecated now, with the recommended
starting point being the VelocityViewServlet/VelocityLayoutServlet instead.

I'd strongly suggest you look at the whole of the VelocityStruts
sub-project (http://jakarta.apache.org/velocity/tools/struts/) which
uses the VelocityViewServlet for processing of templates. This includes
some pretty good documentation showing you how to get started.

In very basic terms, you populate the (request) context within your
Struts actions, and then forward the request to a Velocity template
which is processed by the VelocityViewServlet to print your output to
the client. Note that Struts need have no idea that Velocity is being
used for the View.

- s


Paul Goepfert wrote:
> I have written a servlet that extends from VelocityServlet. I am not
> sure how to intergrate it into my velocity/struts app.  As of now all
> my actions such as moving from page to page are handled by struts
> using the VelStruts tool, $link.setAction().  I have been reading up
> on velocity from a book called "Mastering Apache Veloicty".  The book
> helped me out a lot.  The only thing that I noticed was that there was
> no reference to a struts/velocity web app.  I also bought a book on
> struts.  In that book there is a paragraph on velocity but nothing to
> show me how to utlize struts/velocity together.
> 
> Would someone please show me a way to intergrate my new class into my
> struts app.  I should tell you that I have overwritten the
> handleRequest method in VelocityServlet.
> 
> 
> -Paul
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Have a question about intergrating a Velocity servlet into my velocity/struts app

Posted by Nathan Bubna <nb...@gmail.com>.
On 6/19/05, Paul Goepfert <pa...@gmail.com> wrote:
> I have written a servlet that extends from VelocityServlet. I am not
> sure how to intergrate it into my velocity/struts app.  As of now all
> my actions such as moving from page to page are handled by struts
> using the VelStruts tool, $link.setAction().  I have been reading up
> on velocity from a book called "Mastering Apache Veloicty".  The book
> helped me out a lot.  The only thing that I noticed was that there was
> no reference to a struts/velocity web app.  

that book was printed before the advent of the VelocityTools project
(which includes VelocityStruts support).

> I also bought a book on
> struts.  In that book there is a paragraph on velocity but nothing to
> show me how to utlize struts/velocity together.

The only Struts book i've heard of that dealt with VelocityStruts was
Ted Husted's (the title escapes me at the moment), and that was only a
chapter that talked about pre-1.0 VelocityTools stuff.  VelocityTools
has come far since then.  you're best bet is to read up on the
VelocityTools docs, play around with the example apps that it comes
with, and ask specific questions on this list. :)

> Would someone please show me a way to intergrate my new class into my
> struts app.  I should tell you that I have overwritten the
> handleRequest method in VelocityServlet.

if you really want to stick with your VelocityServlet subclass (which
i strongly recommend against), then you'd best look into the source
code for the VelocityViewServlet and friends.  the ChainedContext
class is particularly useful for integration with Struts' Actions
because it automatically exposes request attributes (which can be set
in your action class).

> 
> -Paul
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org