Skip to Content

Retrieving a cookie from session component

Hi,

Is it possible to retrieve a variable in the java part of a JSPDynPage set with EPCM.storeClientData() in the client part (javascript)?

Normally I’m doing it by using a hidden input field as data container, but I would like to keep the JSP code to a minimum 😊

I have read in some other posts that it should be possible to access the variable through the session component.

I have tried to get it working, but without any luck 😔

So what have I been doing. In the sender iView I have the following Javascript setting the variable and raising an event:

<script>

function fireEvent(evtData){

EPCM.storeClientData( 'urn:com.myDomain', 'eventDataBag', evtData);

alert( EPCM._private.printClientDataBag() );

EPCM.raiseEvent( 'urn:com.myDomain', 'eventTest', evtData );

}

</script>

And in the receiver iView I have the following Javascript for reloading the iView.

<script>

EPCM.subscribeEvent( 'urn:com.myDomain', 'eventTest', <%=jsFunctionName%> );

function <%=jsFunctionName%> ( evt ) {

alert( EPCM._private.printClientDataBag() );

document.all.<%=eventButtonElementId%>.click();

}

</script>

So far no problem.

Now I want to get the variable from the session component in the doProcessBeforeOutput() method.

public void doProcessBeforeOutput() throws PageException {

IPortalComponentRequest request =

(IPortalComponentRequest) this.getRequest();

IPortalComponentResponse response =

(IPortalComponentResponse) this.getResponse();

response.write(

"getValue: "

+ request.getComponentSession().getValue("eventDataBag")

+ "<br/>");

setJspName("receiver.jsp");

}

I’m not getting any value. What am I doing wrong, is there some thing I have forgotten or is it just not possible?

Best regards,

Henrik

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2004 at 11:19 AM

    Well, after looking at the EPCM implmentation it normally uses cookies to store the result (unles you are using the java applet level which you normally wouldn't).

    In principle, you could therefore get the values from using the getCookies method in the IPortalComponentRequest (or HttpServletRequest). But, there is no free lunch, and the name of the cookie is probably dynamic and the contents might be a bit altered.

    Try some debug information on the cookies

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.