Message Boards

Denied Access in Freemarker Template

Mohamed Saleem, modified 2 Years ago.

Denied Access in Freemarker Template

Junior Member Posts: 37 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 2 Years ago.

RE: Denied Access in Freemarker Template

Liferay Legend Posts: 6403 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)