PDA

View Full Version : session problem


mallesh
03-11-2004, 06:13 AM
HI Antun,

I am maintaining the session in my application.Here,If i call the JSP page from the lzx with absolute path like (http://localhost:8080/appl/jsp/mysession.jsp)it always create the new session object.But if call it with relative path like (/mysession.jsp)then it works fine.But i want to put my jsp page in some other folder and call it from my application so it need absolute path.At the same time i need to maintain the session(that should not create new session for each request).So how can do that?


Thanks
Mallesh

hqm
03-11-2004, 06:21 AM
Do you mean you are calling a .jsp file using the data API? Do you have some sample lines of code we could see?

changski
12-16-2004, 11:00 AM
I have the same problem. I'm using your sample code (from session_example.zip). What has been modified are the following:
1. In "mysession.jsp", add the following line to display the session in server side:
System.out.println("\t session = " + session);

2. Put "mysession.jsp" somewhere eles in the Tomcat server, say: TOMCAT_HOME\webapps\another-web-app

3. In "session.lzx", set the dataset src from src="mysession.jsp" to src="../../another-web-app/mysession.jsp" or src="http://localhost:8080/another-web-app/mysession.jsp"

run the session.lzx and look at the tomcat server window, each time you click the "Set session value" button, the value of seesion are different.

That means each you do the "myDataset.doRequest()", you will lost current session and got a new session.

How can I keep my session while using a jsp datasource other than lzx folder?

viraf
12-17-2004, 07:26 AM
Doesnt each webapp gets its own session?

changski
12-17-2004, 08:10 AM
I'm not sure if someone knows how to deal with the session between requests?

Please use the attached file or the code below.

Scenario 1:
If you put the jsp and lzx files in the same folder then set src="mysession.jsp" then each time you click the "do some request" button you will get the same session value, that's fine.

Scenario 2:
But if you put the jsp and lzx files in the different folder(or web server) then set src="..\..\mysession.jsp"(or "http:://another-webserver\mysession.jsp") then each time you click the "do some request" button you will get the different session value, that means you each time you do your request you will use a new session and you lost your current one.

My question is how to keep the session unchanged between each request in scenario#2?

Thanks in advance.
Changski



Here is the content of jsp file:
<%@ page contentType="text/xml" %>
<response session_value="<%=session.hashCode()%>"/>

And here is the content of lzxfile:
<canvas width="240">
<debug y="150" />

<dataset name="myDataset"
src="../../../questionnairesv_webservice/mysession.jsp" type="http" autorequest="true" />

<simplelayout axis="y" spacing="15" />

<text width="200" x="25" multiline="true">
The current session is:
</text>

<text name="variable_value" align="center" resize="true"
datapath="myDataset:/response/@session_value" />

<button align="center">do some request
<method event="onclick">
myDataset.doRequest();
</method>
</button>
</canvas>