Parameters must be passed between an HTTP request and a Cloud session if the user wishes to launch the application from an http://host/mywebapp/index.jsp?param1=xxx¶m2=yyy-type URL.
A Cloud session is independent from the HTTP session in the JEE sense.
A Cloud session is linked to the websocket lifecycle. The websocket JSR-356 specifications ensure complete isolation between the http session (javax.servlet.http.HttpSession) and a websocket session (javax.websocket.Session), as they both have a separate lifecycle.
Within the framework, it is therefore advisable to define the passage of information between a javax.servlet.http.HttpServletRequest and a Cloud session.
Operating principle
The upstream server (index.jsp) has an API in order to pass <key,value> pairs when opening the http session.
These pairs are then accessible in the application's Cloud session.
Example of main servlet index.jsp encapsulation:
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="adelwagon" uri="http://adelwagon.adelia.hardis.com/adelwagon" %> <adelwagon:pushCustomVariable key="param1"><%=request.getParameter("param1")%></adelwagon:pushCustomVariable><adelwagon:pushCustomVariable key="param2" cipher="true"><%=request.getParameter("param2")%></adelwagon:pushCustomVariable> <t:adeliaDesktop title="Adelia Desktop" desktopName="default" frameOptions="SAMEORIGIN"> <jsp:attribute name="head_header"> <adelwagon:customSessionVariables/> <link href="logo/logo.css" rel="stylesheet" type="text/css"/> </jsp:attribute> <jsp:attribute name="head_footer"> </jsp:attribute><jsp:attribute name="body_header"> </jsp:attribute><jsp:attribute name="body_footer"> </jsp:attribute> </t:adeliaDesktop>
|
Passing parameters
Creating customised <key,value> pairs; using the tag:
<adelwagon:pushCustomVariable key="clef" [cipher="true|false"]>valeur</adelwagon:pushCustomVariable>
|
Note: The <key,value> pair appears in the flow of the generated web page. If the value contains confidential information, it is possible to encode its content using the cipher="true".
Example of passing two <mykey,mycleardata> and <mysecret,myconfidentialdata> pairs
In this example, the user retrieves mykey from a URL parameter and mysecret from a request attribute:
<adelwagon:pushCustomVariable key="mykey"><%=request.getParameter("mycleardata")%></adelwagon:pushCustomVariable> <adelwagon:pushCustomVariable key="mysecret" cipher="true"><%=request.getAttribute("myconfidentialdata")%></adelwagon:pushCustomVariable>
|
Retrieving parameters from a Java class
String myKey = (String) this.getSessionContext().getMainContainerConfiguration().getAttributes().get("custom.key"); String mySecret = WagonCipher.getInstance().decode((String) this.getSessionContext().getMainContainerConfiguration().getAttributes().get("custom.mysecret"));
|
Note: the mykey key is accessible at session attribute level by prefixing it with custom.
Retrieving parameters from a VisualAdelia program
ALPHA(256) W_CUSTOMKEY ALPHA(1024) W_MYKEY ALPHA(1024) W_MYSECRETW_CUSTOMKEY='custom.mykey'APPELER_CLASS 'vatoolbx' 'VaToolBxCloudGetSessionAttribute' W_CUSTOMKEY W_MYKEY 1024W_KEY='custom.mysecret' APPELER_CLASS 'vatoolbx' 'VaToolBxCloudGetSessionAttribute' W_CUSTOMKEY
|