velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claude Brisson <>
Subject Re: getting list of all context values
Date Wed, 18 Oct 2006 08:43:25 GMT
By default, the context is not included in itself, but you can still
list the values in the session, request or response (or also in the
servlet context, known as "application") with the following loops:

#foreach($key in $request.attributeNames) ...

#foreach($key in $session.attributeNames) ...

#foreach($key in $application.attributeNames) ...

If you need the context to have a key towards itself, you have to
subclass the VelocityViewServlet, and inherit createContext like this:

    protected Context createContext(HttpServletRequest request, 
                                    HttpServletResponse response)
       Context context = super.CreateContext(request,response);

You can then iterate on values of the context like this:

#foreach($key in $context.keys)
<li>$key = $context.get('$key')

but the values in the request, session, response and application won't
appear in this list.


Le mardi 17 octobre 2006 à 18:18 -0400, Charles Harvey III a écrit :
> Hello.
> If I am using the VelocityLayoutServlet where all things that I put into
> the request, response and session automatically go into the $context.
> So... how do I get a list of all the values in the $context?  Just for
> starters, how do I access the $context?  It is not with "$context".
> I can access $request, $response and $session.  So, how do I get at the
> $context?
> Thanks much.
> Charlie
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message