<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Tahoma}
@font-face
        {font-family:Consolas}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
span.emailstyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
span.EmailStyle19
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
span.EmailStyle20
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
span.PlainTextChar
        {font-family:Consolas}
.MsoChpDefault
        {font-size:10.0pt}
@page Section1
        {margin:70.85pt 70.85pt 70.85pt 70.85pt}
div.Section1
        {}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Paul,</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thanks for your reply. Here is the code.</span></p>
<p class="MsoNormal"><span style="color:#1F497D">HttpSession sess = request.getSession(true);</span></p>
<p class="MsoPlainText">sess.setAttribute("whitePaperRegistrationMailId",regDetails.getEmailId());</p>
<p class="MsoPlainText">String mailId = (String)sess.getAttribute("whitePaperRegistrationMailId");</p>
<p class="MsoPlainText">out.println("Mail id is :"+mailId); //This is working fine in same JSP.</p>
<p class="MsoPlainText"> </p>
<p class="MsoPlainText">When I am trying to access from another JSP with the below code, I am getting null value.</p>
<p class="MsoNormal"><span style="color:#1F497D">HttpSession sess = request.getSession(false);</span></p>
<p class="MsoPlainText">String mailId = (String)sess.getAttribute("whitePaperRegistrationMailId");</p>
<p class="MsoPlainText">out.println("Mail id is :"+mailId); //I am getting null value.</p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">I think the problem is with OpenCMS. Does OpenCMS provide any session management?</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thanks,</span></p>
<p class="MsoNormal"><span style="color:#1F497D">Sankar.K</span></p>
<div>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif""> opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org]
<b>On Behalf Of </b>Paul-Inge Flakstad<br>
<b>Sent:</b> Wednesday, January 23, 2013 4:40 PM<br>
<b>To:</b> The OpenCms mailing list<br>
<b>Subject:</b> Re: [opencms-dev] State shared between the JSPs</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="color:#1F497D">Hi Sankar,</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">You do realize you’re trying to modify a final object in your illustration code..?</span></p>
<p class="MsoNormal"><span style="color:#1F497D">final CmsRequestContext requestContext = cmsObject.getRequestContext();</span></p>
<p class="MsoNormal"><span style="color:#1F497D">requestContext.setAttribute("someObj ", someObj);</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Anyway -- my preferred recipe goes like this:</span></p>
<p class="MsoNormal"><span style="color:#1F497D">// Fetch the session object (don’t use the implicitly available variable “session”)</span></p>
<p class="MsoNormal"><span style="color:#1F497D">HttpSession sess = request.getSession(true); // You may or may not want to pass the boolean here</span></p>
<p class="MsoNormal"><span style="color:#1F497D">// Then do like this:</span></p>
<p class="MsoNormal"><span style="color:#1F497D">sess.setAttribute(...);</span></p>
<p class="MsoNormal"><span style="color:#1F497D">sess.getAttribute(...);</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Not forgetting to put session="true" in the @page directive:</span></p>
<p class="MsoNormal"><span style="color:#1F497D"><%@page import=”...” session=”true” %></span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">You should also be able to use request.setAttribute(...) and request.getAttribute(...) -- just like that, using the implicitly available variable “request”. (The stored object will of course live only for as
 long as the request lives.)</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">NOTE: If you’re using flex cache, be aware. It doesn’t always play nice with this. It’s supposed to work (if configured correctly) with the session approach, but I’ve had to disable flex cache for some of my
 JSPs where I do stuff like this.</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">HTH :)</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Cheers,</span></p>
<p class="MsoNormal"><span style="color:#1F497D">Paul</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<div>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif""> opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org]
<b>On Behalf Of </b>Karri Sankar Rao<br>
<b>Sent:</b> 23. januar 2013 11:16<br>
<b>To:</b> opencms-dev@opencms.org<br>
<b>Subject:</b> [opencms-dev] State shared between the JSPs</span></p>
</div>
</div>
<p class="MsoNormal"><span lang="NO-BOK"> </span></p>
<div>
<p class="MsoNormal">Hi,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I am working on OpenCMS application. I am new to OpenCMS.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I have one object which I want to keep it in session so that I can use it in other JSPs.</p>
<p class="MsoNormal">I tried in 2 ways to get this.</p>
<p class="MsoListParagraph" style="text-indent:-.25in">a)<span style="font-size:7.0pt; font-family:"Times New Roman","serif"">     
</span>Initially I used JSP implicit variable i.e session.setAttribute(“someObj”,someObj). But this session object is not available in other JSPs. I am getting null when I try to retrieve using session.getAttribute(“someObj”);</p>
<p class="MsoListParagraph" style="text-indent:-.25in">b)<span style="font-size:7.0pt; font-family:"Times New Roman","serif"">     
</span>Then I used another approach.</p>
<p class="MsoListParagraph">CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);</p>
<p class="MsoListParagraph">final CmsObject cmsObject = cms.getCmsObject();</p>
<p class="MsoListParagraph">final CmsRequestContext requestContext = cmsObject.getRequestContext();</p>
<p class="MsoListParagraph">requestContext.setAttribute("someObj ", someObj);</p>
<p class="MsoListParagraph"> </p>
<p class="MsoListParagraph">I am not sure whether it is in request scope or session scope. When I tried to access it in another JSP, getting null value.</p>
<p class="MsoListParagraph"> </p>
<p class="MsoListParagraph">CmsJspActionElement cms=new CmsJspActionElement(pageContext, request, response);</p>
<p class="MsoListParagraph">final CmsObject cmsObject = cms.getCmsObject();</p>
<p class="MsoListParagraph">final CmsRequestContext requestContext = cmsObject.getRequestContext();</p>
<p class="MsoListParagraph">Object obj = requestContext.getAttribute("someObj ");</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Could you please let me know how to resolve this.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Your help is highly appreciated.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Sankar.K</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt; font-family:"Times New Roman","serif"">Disclaimer: "The materials contained in this email and any attachments may contain confidential or legally privileged information. The information contained in this communication
 is intended solely for the use of the individual or entity to whom it is addressed and others authorized to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance
 on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. Sonata is neither liable for the
 proper and complete transmission of the information contained in this communication nor for any delay in its receipt"
</span></p>
</div>
Disclaimer: "The materials contained in this email and any attachments may contain confidential or legally privileged information. The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed
 and others authorized to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If
 you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. Sonata is neither liable for the proper and complete transmission of the information contained in this communication
 nor for any delay in its receipt"
</body>
</html>