RE: Denied Access in Freemarker Template

Jamie Sammons, modified 3 Years ago. Junior Member Posts: 40 Join Date: 12/16/15 Recent Posts

Hi, 

I am using request.getSession() in freemarker template to set some attribute , It is working in Dev Environment

In QA and Prod It is throwing Errror 

 

Example,

${request.getSession().setAttribute("title", "Title")}

Below Error I am getting

Denied access to method or field setAttribute of class org.apache.catalina.session.StandardSessionFacade

----
FTL stack trace ("~" means nesting-related):
    - Failed at: ${request.getSession().setAttribute(t...  [in template "34393807#34393846#null" at line 59, column 9]

 

If any one knows please help me.

 

Thanks.

thumbnail
Olaf Kock, modified 3 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Q1: Which version?
​​​​​​​Q2: Did you compare both installations' configuration? E.g. Template classes can (and should) be denied access to most of the underlying runtime environment, and I'd rather consider this a feature than a problem

General Statement: A freemarker template should not contain any code like this at all. It's meant to create the UI, not store arbitrary stuff in sessions (in fact, nothing should be stored there ever - it hinders load-balancer-fail-overs, eats up your memory, and makes your code unmaintainable)