You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Wojtek Rappak <ra...@nildram.co.uk> on 2002/05/29 13:32:48 UTC

Context object scope ?

I assume that in the servlet implementation of velocity the context object
has request rather than session scope.

Is that correct?

Wojtek Rappak



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


Re: Context object scope ?

Posted by Christoph Reck <Ch...@dlr.de>.
Wojtek Rappak wrote:
> 
> I assume that in the servlet implementation of velocity the context object
> has request rather than session scope.
> 
> Is that correct?
> 
> Wojtek Rappak
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

Yes. The default velocity context should not be modified concurrently in 
multiple threads, so it is request based.

Please note that you can enhance the VelocityServlet to return you own session
based context chained in a request context. You can also pre-populate a
context and reuse this (again by chaining it in a request context) troughout
an application.

Another solution for a session based context is to use the session object
itself: $req.getSession(true).putAttribute(...)
see the servlet specification (2.3 for tomcat-catalina) for more 
information.

-- 
:) Christoph Reck

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