In my global.jsp file on line 44 I have
I want to try use session such as
session.setAttribute(userIDKey, userID);
on a jsp page.
in global.jsp I have
--%><%@page session="false" import="javax.jcr.*,
If I change it to
--%><%@page session="true" import="javax.jcr.*,
then every page I try display give
/libs/foundation/global.jsp(44,4) Page directive: illegal to have multiple occurrences of session with different values (old: false, new: true)
else
If I leave global.jsp with
--%><%@page session="false" import="javax.jcr.*,
And I try enable session on my jsp page
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/libs/foundation/global.jsp"%>
<%@page session="true"%>
I get
org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: /apps/components/comps/compponentexample/compponentexample.jsp(3,0) Page directive: illegal to have multiple occurrences of session with different values (old: false, new: true)
Is there a way to be able to use session object in aem 6.1
Solved! Go to Solution.
Views
Replies
Total Likes
Modify content under libs is not best practice - that includes /libs/foundation/global.jsp.
Getting a session in JSP is similiar to using Java on backend. Here is a community article that show you the syntax:
http://teknopoint.us/adobe-cq5-code-snippets-cheat-shs/
(I personally prefer using OSGi to create sessions and perform CRUD operations on JCR data that require a session)
Views
Replies
Total Likes
Modify content under libs is not best practice - that includes /libs/foundation/global.jsp.
Getting a session in JSP is similiar to using Java on backend. Here is a community article that show you the syntax:
http://teknopoint.us/adobe-cq5-code-snippets-cheat-shs/
(I personally prefer using OSGi to create sessions and perform CRUD operations on JCR data that require a session)
Views
Replies
Total Likes
Thank you Scott,
I will use your recommendation use an OSGI bundle to set and retrieve session values on the JCR.
Regards
Clive Stewart
Views
Replies
Total Likes
Hi Clive,
what is your use case for maintaining a session? What data are you wanting to use across requests?
Regards,
Opkar
Views
Replies
Total Likes