PDA

View Full Version : SOLO and Sessions


yairiny
03-26-2006, 05:58 AM
Hi,

I have seen this discussed before in the forums (using search of course), but have not found a definitive answer to this.

The documentation states that in order for the requests from the Laszlo application to maintain session, we cannot use SOLO. Well, I have a simple SOLO app which seems to maintain the sesion well, I have even tried running it twice from two browser instances and it seems to work just fine. I am looking for a definitive answer to this from people in the know

Here is my code:

lzx file:
<!DOCTYPE canvas SYSTEM "lzx.dtd">
<canvas height="100%" width="100%">
<include href="lz/tree.lzx"/>

<dataset name="aternity" type="http" src="data1.jsp" request="true"/>

<view layout="axis: y; spacing: 10">
<tree datapath="aternity:/aternity/" showroot="false">
<tree datapath="location" text='${this.datapath.xpathQuery("@name")}'>
<tree datapath="office" text='${this.datapath.xpathQuery("@name")}'>
<tree datapath="department" text='${this.datapath.xpathQuery("@name")}' isleaf="true"/>
</tree>
</tree>
</tree>
<button text="UpdateView" onclick="updateView()" >
<method name="updateView">
<![CDATA[
canvas.aternity.doRequest();
]]>
</method>
</button>
</view>
</canvas>

jsp file:

<%@ page import="java.util.Random"%>
<%@ page contentType="application/xml;charset=UTF-8" language="java" %>
<%
Thread.sleep(3000);
Random rand = new Random(System.currentTimeMillis());
boolean val = rand.nextBoolean();
if ( val ) {
System.out.println("true");
}
else {
System.out.println("false");
}

//get the session object
System.out.println("session = " + session);
%>
<aternity>
<% if ( val ) {%>
<location name="Israel">
<office name="Hod Hasharon">
<department name="Administration"/>
<department name="R&amp;D"/>
</office>
</location>
<%}else {%>
<location name="USA">
<office name="Boston">
<department name="Administration"/>
<department name="Marketing"/>
<department name="Sales"/>
</office>
</location>
<%}%>
</aternity>

Thanks,
Yair Iny

Dan5
03-26-2006, 02:31 PM
Hi,

I think when people talk about SOLO apps not being able to support sessions they are referring to a specific implementation of sessions implemented by the Laszlo server. When an app is SOLO the Laszlo server isn't there hence this sort of sessions isn't supported.

However there are many way to implement the feature of sessions at the application level which is what I assume you are doing.

In my own SOLO app I use sessions, my solution is different from yours as my app is using a legacy login system which is just regular html running a php backend with the session data stored in a MySQL database. My SOLO app retrieves the session value from the browser cookie using JavaScript and makes sure it passes the value back whenever it makes a request to the server. The server can authenticate each request the user makes and passes back the appropriate data.

Dan

explorer
03-27-2006, 07:58 AM
I was a little confused about this also. Because like you I created a simple SOLO app and had it call a backend Servlet with a session that kept a simple counter. Like you I could see that the session was being kept between the SOLO app and the back end server.

I must be what Dan says, a confusion with the Laszlo session and a standard web sessions (for lack of a better description).

I am glad to see I was not the only one confused by that.