PDA

View Full Version : Problems with JSESSIONID


dybomaha
08-17-2004, 02:28 PM
I have read several other threads about this problem, but I don't seem to be able to fix it.

When I use my Laszlo app to log into the thread, it cannot get the session ID or maintain the session state. Is Laszlo not sending the cookies back with every request?

We have two servlets, one for login and one for logout. When I log into the first servlet, the Laszlo app posts it's data to the servlet just fine, and then when I try to log out, it fails because the logout servlet can't find the session state.

This works under a browser. The servlets connect to our EJBs under JBOSS.

The actual file is shown below:

<canvas title="Auctionetics Auction Manager" bgcolor="#ffffff" height="768" width="1024" debug="true">

<script>
var session = null;
</script>

<splash/>

<debug width="400" height="200" x="200" y="300" fontsize="8"/>
<font name="Arial" src="bitstream-vera-1.10/vera.ttf"/>

<dataset name="dsLogin" request="false" src="/AuctionWeb/FrontDesk/Signon" type="http"/>
<dataset name="dsLogout" request="false" src="/AuctionWeb/FrontDesk/Logout" type="http"/>

<view resource="http://www.auctionetics.com/images/auctionetics_top.gif"/>

<text x="285" y="11" width="200" height="35" name="name">
<animator name="nameAnimator1" attribute="x" to="100" duration="1000" start="false" relative="true"/>
<animator name="nameAnimator2" attribute="x" to="-100" duration="1000" start="false" relative="true"/>
<font face="Arial" size="24">Not Logged In</font></text>

<button x="725" y="10" name="logout" visible="false" onclick="doLogout();">Log Out
<method name="doLogout">
<![CDATA[
var d=canvas.datasets.dsLogout;
var p=new LzParam();
debug.write("Sending request for logout.");
if(session && session.length() > 0) {
p.addvalue("JSESSIONID", session, true);
}
d.setQueryString( p );
d.doRequest();
LzBrowser.loadURL('javascript:alert(document.cooki e)');
]]>
</method>
</button>

<window x="20" y="60" title="Login" name="login" height="205" width="325">
<text x="2" y="2" width="200" height="35">
<font face="Arial" size="24">User Login</font></text>
<text x="20" y="45">Member ID:</text>
<edittext width="200" x="100" y="40" name="memberId">num</edittext>
<text x="20" y="75">User ID:</text>
<edittext width="200" x="100" y="70" name="userId">user</edittext>
<text x="20" y="105">Login:</text>
<edittext password="true" width="200" x="100" y="100" name="password">pass</edittext>
<button width="75" x="215" y="135" onclick="doLogin();">Login
<method name="doLogin">
<![CDATA[
var d=canvas.datasets.dsLogin;
var p=new LzParam();
debug.write("sending request for login.");
if(session && session.length() > 0) {
p.addvalue("JSESSIONID", session, true);
}
p.addvalue("memberId", canvas.login.memberId.getText(), true);
p.addvalue("userId", canvas.login.userId.getText(), true);
p.addvalue("password", canvas.login.password.getText(), true);
d.setQueryString( p );
d.doRequest();
LzBrowser.loadURL('javascript:alert(document.cooki e)');
]]>
</method>
</button>
</window>

<datapointer xpath="dsLogin:/frontDeskLogin/">
<method event="ondata">
debug.write("Got some data back.");

debug.write("MESSAGE: " + this.xpathQuery( "status/message/text()") );
debug.write("NAME: " + this.xpathQuery( "data/name/text()") );
debug.write("CODE: " + this.xpathQuery( "status/code/text()") );
debug.write("JSESSION: " + this.xpathQuery( "status/jsessionid/text()") );

session = this.xpathQuery( "status/jsessionid/text()");

if ( this.xpathQuery( "status/message/text()" ) == "Success" ) {
Debug.write( "Login Succeeded" );
<![CDATA[
canvas.name.setText("<font face=\"Arial\" size=\"24\">" +
this.xpathQuery( "data/name/text()" ) +
"</font>");
]]>
canvas.login.setVisible(false);
canvas.name.nameAnimator1.doStart()
canvas.name.nameAnimator2.doStart()
canvas.logout.setVisible(true);
} else {
Debug.write( "Login Failed" );
}
</method>
</datapointer>

<datapointer xpath="dsLogout:/frontDeskLogout/">
<method event="ondata">
debug.write("Got some data back.");
if ( this.xpathQuery( "status/message/text()" ) == "Success" ) {
Debug.write( "Logout Succeeded" );
<![CDATA[
canvas.name.setText("<font face=\"Arial\" size=\"24\">" +
"Not Logged In" +
"</font>");
]]>
canvas.name.nameAnimator1.doStart()
canvas.name.nameAnimator2.doStart()
canvas.login.setVisible(true);
canvas.logout.setVisible(false);
} else {
Debug.write( "Logout Failed" );
}
</method>
</datapointer>

</canvas>



From the DEBUG code above, I get the following:

sending request for login.
Got some data back.
MESSAGE: Success
NAME: White, Rod J
CODE: 0
JSESSION: 6DF12F82D2E2FA0A67E5E72A3A0654D2
GOT SESSION: 6DF12F82D2E2FA0A67E5E72A3A0654D2
Login Succeeded
Sending request for logout.
LOGOUT SESSION: 6DF12F82D2E2FA0A67E5E72A3A0654D2
Got some data back.
USING SESSION: 6DF12F82D2E2FA0A67E5E72A3A0654D2
Logout Succeeded

So, the JSESSION id is not passed back to the server? It should be the same in the debug output, not changing.

I don't understand why Laszlo is not just handling the coookies. For interested parties, I can post the actual URL for you to hit. But, it may cause my IP allocation to be overrun, right?

DYBOMAHA

dybomaha
08-17-2004, 07:25 PM
I modified one section as follows:


<datapointer xpath="dsLogin:/frontDeskLogin/">
<method event="ondata">
debug.write("Got some data back.");

debug.write("MESSAGE: " + this.xpathQuery( "status/message/text()") );
debug.write("NAME: " + this.xpathQuery( "data/name/text()") );
debug.write("CODE: " + this.xpathQuery( "status/code/text()") );
debug.write("JSESSION: " + this.xpathQuery( "status/jsessionid/text()") );

session = this.xpathQuery( "status/jsessionid/text()");

debug.write("GOT SESSION: " + session);

if ( this.xpathQuery( "status/message/text()" ) == "Success" ) {
Debug.write( "Login Succeeded" );
<![CDATA[
canvas.name.setText("<font face=\"Arial\" size=\"24\">" +
this.xpathQuery( "data/name/text()" ) +
"</font>");
]]>
canvas.login.setVisible(false);
canvas.name.nameAnimator1.doStart()
canvas.name.nameAnimator2.doStart()
canvas.logout.setVisible(true);
var s ='javascript:';
s += 'document.cookie="JSESSIONID='+ session;
s += '"; void(0);';
LzBrowser.loadURL( s );
} else {
Debug.write( "Login Failed" );
}
</method>
</datapointer>


The session ID is sent in the XML from the servlet, and then the session ID is pushed to the browser by the Javascript.

Then, futher interactions with the server will attach to the existing session, and I can get data from my EJBs.

NOTE: There should be space in "javascript" - the forum is apparently putting it in there.

DYBOMAHA