views:

61

answers:

1

how can i use session scope in VELOCITY(in view part am using sample.vm like that)... my requirement is when i login into a page,i want to store the user's name& some details in session and if i press logout i want to clear all the information in that session.

thanks for ur help

A: 

When rendering a template with velocity you have to pass a Context which is basically a hash map.

So you copy the stuff from the Session into that Context before rendering the template.

When you press logout, simple destroy the Session object, as per standard practice. Normally you do not need to do anything special for velocity.

Well, this is in the case you call velocity explicitely form a servlet. If you use a framework, it does a lot of this behind the scenes, but even in that case simply disposing the Session will do the trick.

Peter Tillemans
thanks peter .i completed my task in different way,in action class i using this trick HttpServletRequest request.getSession()
Raam