<div dir="ltr"><div><div><div><div>Hi Sankar,<br></div>we had a problem with session too, it was due to opencms was running on Tomcat on context /opencms and we masked it on Nginx server befor Opencms, so it looked like opencms was running on context /<br>
</div>But session is realized by cookie (which is created by Tomcat) and it looks like this:<br><br>JSESSIONID=4871301FB4E4B60F03CAB5DC5AF5CD4D; Path=/opencms<br><br></div>Cookie has a path set, browser then sends this cookie only with requests with path which begins with /opencms. But path was masked by Nginx and request from browser din not have path /opencms. Cookie was not sent and session did not work. Now we are running OpenCms directly on Tomcat on context / and session works properly.<br>
<br></div>Ladislav Kulhanek<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/23 Paul-Inge Flakstad <span dir="ltr"><<a href="mailto:flakstad@npolar.no" target="_blank">flakstad@npolar.no</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="NO-BOK"><div><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Hi again Sankar,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">OK, I trust it’s not that then. I see you’re passing “false” in your 2<sup>nd</sup> JSP when you’re getting the session object. You should probably pass “true” or nothing all. <u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Here’s a real example, in use right now on one of our sites. It works like a charm.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">JSP A:<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HttpSession sess = request.getSession(true); // Passing “true” here, even though I probably don’t have to<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">sess.setAttribute("share", "true"); <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">JSP B:<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HttpSession sess = request.getSession(); // Note I’m not passing no argument here<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">if (sess.getAttribute("share") != null && sess.getAttribute("share").equals("true")) {<u></u><u></u></span></p><p class="MsoNormal">
<span style="color:#1f497d" lang="EN-US"> // Do stuff<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">}<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Please try something like this. Let us know how it goes.<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Best regards,<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Paul<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [mailto:<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a>] <b>On Behalf Of </b>Karri Sankar Rao<br>
<b>Sent:</b> 23. januar 2013 12:47</span></p><div><div class="h5"><br><b>To:</b> The OpenCms mailing list<br><b>Subject:</b> Re: [opencms-dev] State shared between the JSPs<u></u><u></u></div></div><p></p></div></div><div>
<div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Hi Paul,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">In both JSP pages, session=”true” in page directives.</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Thanks,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Sankar.K</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal">
<b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">mailto:opencms-dev-bounces@opencms.org</a>] <b>On Behalf Of </b>Paul-Inge Flakstad<br>
<b>Sent:</b> Wednesday, January 23, 2013 5:15 PM<br><b>To:</b> The OpenCms mailing list<br><b>Subject:</b> Re: [opencms-dev] State shared between the JSPs</span><span lang="EN-US"><u></u><u></u></span></p></div></div><p class="MsoNormal">
<span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Hi again Sankar,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">The issue is not related to OpenCms, I assure you. Do you have session="true" in your @page directives?</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Best regards,</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Paul</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">mailto:opencms-dev-bounces@opencms.org</a>] <b>On Behalf Of </b>Karri Sankar Rao<br>
<b>Sent:</b> 23. januar 2013 12:43<br><b>To:</b> The OpenCms mailing list<br><b>Subject:</b> Re: [opencms-dev] State shared between the JSPs</span><span lang="EN-US"><u></u><u></u></span></p></div></div><p class="MsoNormal">
<span lang="EN-US"><u></u><u></u></span></p><div><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Hi Paul,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Thanks for your reply. Here is the code.</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HttpSession sess = request.getSession(true);</span><span lang="EN-US"><u></u><u></u></span></p>
<p><span lang="EN-US">sess.setAttribute("whitePaperRegistrationMailId",regDetails.getEmailId());<u></u><u></u></span></p><p><span lang="EN-US">String mailId = (String)sess.getAttribute("whitePaperRegistrationMailId");<u></u><u></u></span></p>
<p><span lang="EN-US">out.println("Mail id is :"+mailId); //This is working fine in same JSP.<u></u><u></u></span></p><p><span lang="EN-US"> <u></u><u></u></span></p><p><span lang="EN-US">When I am trying to access from another JSP with the below code, I am getting null value.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HttpSession sess = request.getSession(false);</span><span lang="EN-US"><u></u><u></u></span></p><p><span lang="EN-US">String mailId = (String)sess.getAttribute("whitePaperRegistrationMailId");<u></u><u></u></span></p>
<p><span lang="EN-US">out.println("Mail id is :"+mailId); //I am getting null value.<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">I think the problem is with OpenCMS. Does OpenCMS provide any session management?</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Thanks,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Sankar.K</span><span lang="EN-US"><u></u><u></u></span></p>
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">mailto:opencms-dev-bounces@opencms.org</a>] <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><span lang="EN-US"><u></u><u></u></span></p></div></div><p class="MsoNormal">
<span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Hi Sankar,</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">You do realize you’re trying to modify a final object in your illustration code..?</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">final CmsRequestContext requestContext = cmsObject.getRequestContext();</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">requestContext.setAttribute("someObj ", someObj);</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Anyway -- my preferred recipe goes like this:</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">// Fetch the session object (don’t use the implicitly available variable “session”)</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HttpSession sess = request.getSession(true); // You may or may not want to pass the boolean here</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal">
<span style="color:#1f497d" lang="EN-US">// Then do like this:</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">sess.setAttribute(...);</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">sess.getAttribute(...);</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Not forgetting to put session="true" in the @page directive:</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><<a href="mailto:%25@page%20import=" target="_blank">%@page import=”...” session=”true” %</a>></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">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><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">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><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">HTH :)</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Cheers,</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">Paul</span><span lang="EN-US"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">mailto:opencms-dev-bounces@opencms.org</a>] <b>On Behalf Of </b>Karri Sankar Rao<br>
<b>Sent:</b> 23. januar 2013 11:16<br><b>To:</b> <a href="mailto:opencms-dev@opencms.org" target="_blank">opencms-dev@opencms.org</a><br><b>Subject:</b> [opencms-dev] State shared between the JSPs</span><span lang="EN-US"><u></u><u></u></span></p>
</div></div><p class="MsoNormal"> <span lang="EN-US"><u></u><u></u></span></p><div><p class="MsoNormal"><span lang="EN-US">Hi,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US">I am working on OpenCMS application. I am new to OpenCMS.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">I have one object which I want to keep it in session so that I can use it in other JSPs.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I tried in 2 ways to get this.<u></u><u></u></span></p><p><span lang="EN-US">a)</span><span style="font-size:7.0pt;font-family:"Times New Roman","serif"" lang="EN-US"> </span><span lang="EN-US">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”);<u></u><u></u></span></p>
<p><span lang="EN-US">b)</span><span style="font-size:7.0pt;font-family:"Times New Roman","serif"" lang="EN-US"> </span><span lang="EN-US">Then I used another approach.<u></u><u></u></span></p><p>
<span lang="EN-US">CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);<u></u><u></u></span></p><p><span lang="EN-US">final CmsObject cmsObject = cms.getCmsObject();<u></u><u></u></span></p><p>
<span lang="EN-US">final CmsRequestContext requestContext = cmsObject.getRequestContext();<u></u><u></u></span></p><p><span lang="EN-US">requestContext.setAttribute("someObj ", someObj);<u></u><u></u></span></p>
<p><span lang="EN-US"> <u></u><u></u></span></p><p><span lang="EN-US">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.<u></u><u></u></span></p><p>
<span lang="EN-US"> <u></u><u></u></span></p><p><span lang="EN-US">CmsJspActionElement cms=new CmsJspActionElement(pageContext, request, response);<u></u><u></u></span></p><p><span lang="EN-US">final CmsObject cmsObject = cms.getCmsObject();<u></u><u></u></span></p>
<p><span lang="EN-US">final CmsRequestContext requestContext = cmsObject.getRequestContext();<u></u><u></u></span></p><p><span lang="EN-US">Object obj = requestContext.getAttribute("someObj ");<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Could you please let me know how to resolve this.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Your help is highly appreciated.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Sankar.K<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US"> <u></u><u></u></span></p></div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="EN-US">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><span lang="EN-US"><u></u><u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="EN-US">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><span lang="EN-US"><u></u><u></u></span></p>
</div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"" lang="EN-US">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" <u></u><u></u></span></p>
</div></div></div></div><br>_______________________________________________<br>
This mail is sent to you from the opencms-dev mailing list<br>
To change your list options, or to unsubscribe from the list, please visit<br>
<a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev" target="_blank">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br>
<br>
<br>
<br>
<br></blockquote></div><br></div>