Freemarker Template - User Session context

186 views Asked by At

Will the Freemarker Template support user session similar to JSP?

Can we read and write to user session?

1

There are 1 answers

0
ddekany On

Freemarker itself doesn't care about things like sessions, HTTP requests and the like. It just receives a bunch of objects via the data-model, and then it can access those. So it's up to the web application framework what the templates can do. Modifying a session in an MVC template really smells though. That's the duty of the MVC Controller.

However, if you are using FreemarkerServlet, that creates a data-model that exposes the variables from the request, session and application scopes, and also provides Request, Session, Application variables to read the specific scopes. Though FreemarkerServlet is really just an adapter for legacy or JSP-only apps, otherwise I would avoid it.