You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by wu qi <wq...@yahoo.com> on 2003/03/20 02:19:29 UTC

(velocity-struts) How to add context in action class?

     In a non struts app,we can use add method of context:

        

VelocityContext context = new VelocityContext();

context.put( "name", new String("Velocity") );

 

but for action class in struts ,how to do that?



---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!

Re: (velocity-struts) How to add context in action class?

Posted by Nathan Bubna <na...@esha.com>.
wu qi said:
>      In a non struts app,we can use add method of context:
>
> VelocityContext context = new VelocityContext();
>
> context.put( "name", new String("Velocity") );
>
> but for action class in struts ,how to do that?

just put it in the request attributes:

request.setAttribute("name", "Velocity");

this will have the same effect, because the VelocityViewServlet uses a
ChainedContext that automatically exposes request, session, and servlet
context attributes (among several other things) to the template.

Nathan Bubna
nathan@esha.com



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