[opencms-dev] State shared between the JSPs

Karri Sankar Rao sankarrao.k at sonata-software.com
Wed Jan 23 12:40:14 CET 2013


Hi Georgi,

Thanks for your reply. Here is my code:
session.setAttribute("whitePaperRegistrationMailId",regDetails.getEmailId());
String mailId = (String)session.getAttribute("whitePaperRegistrationMailId");
out.println("Mail id is :"+mailId); //This is working fine in same JSP.

When I am trying to access from another JSP with the below code, I am getting null value.
String mailId = (String)session.getAttribute("whitePaperRegistrationMailId");
out.println("Mail id is :"+mailId); //I am getting null value.

I think the problem is with OpenCMS.

Thanks,
Sankar.K

-----Original Message-----
From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Georgi Naplatanov
Sent: Wednesday, January 23, 2013 4:39 PM
To: The OpenCms mailing list
Subject: Re: [opencms-dev] State shared between the JSPs

Hi Karri.

Managing session's attributes works just fine with OpenCms, check that
session managing code in your JSP is at the top of the JSP file and
there are no HTML tags or white spaces before that code.

Best regards
Georgi

On 01/23/2013 12:16 PM, Karri Sankar Rao wrote:
>
>
> Hi,
>
> I am working on OpenCMS application. I am new to OpenCMS.
>
> I have one object which I want to keep it in session so that I can use
> it in other JSPs.
>
> I tried in 2 ways to get this.
>
> a) 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”);
>
> b) Then I used another approach.
>
> CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
> response);
>
> final CmsObject cmsObject = cms.getCmsObject();
>
> final CmsRequestContext requestContext = cmsObject.getRequestContext();
>
> requestContext.setAttribute("someObj ", someObj);
>
> 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.
>
> CmsJspActionElement cms=new CmsJspActionElement(pageContext, request,
> response);
>
> final CmsObject cmsObject = cms.getCmsObject();
>
> final CmsRequestContext requestContext = cmsObject.getRequestContext();
>
> Object obj = requestContext.getAttribute("someObj ");
>
> Could you please let me know how to resolve this.
>
> Your help is highly appreciated.
>
> Thanks,
>
> Sankar.K
>
> 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"
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev



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"


More information about the opencms-dev mailing list