velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nat...@esha.com>
Subject Re: session object in velocity with velocity-tools
Date Fri, 16 Jul 2004 16:38:29 GMT
Mike Curwen said:
> using velocity tools doesn't magically transform the context into a
> session-level storage space.  If you put something in the Context, then
> it is limited to a single request. just think to yourself "context ==
> request".

yep.

> If you specifically need something in the session, then don't forget
> that Velocity works and plays *very* well with existing servlet API
> objects, like 'HttpSession' and 'ServletContext' (also known as
> 'application').
>
> In your servlet, do :
>
> session.setAttribute("foo", fooObject);
>
> then in your velocity template do:
>
> $session.getAttribute('foo')

actually, if you are using the VelocityViewServlet, then you can just do

$foo

and it will find the session attribute.  but you must still put "foo" into the
session yourself in one of the ways i spelled out in previous emails.

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


Mime
View raw message