Click to See Complete Forum and Search --> : Session attribute problem


javula
03-08-2007, 11:09 AM
Hello there!

I'm working on a web-tier application. I use java, jsp and mysql database. it's my first project, so i don't have lot of experience and knowledge.
My project is about assigning students a seat in lab classrooms.
So, at some point the teacher will fill out a form and submit it. The form's parameters are processed within a servlet and an output(jsp page) with diagrams/charts will appear.
In order for these charts to appear, i save the object(which contains the appropriate data) to the session. Like:
session.setAttribute("objectName", object);

The charts are created in the jsp page.

The problem is that when i go to the main page or to another page and then go back to the charts' page i can no longer see the charts.
I check with a javascript if the object is null and it seems that it is.

The session has not timed out.

Does the attribute no longer exist?

sorry if i'm not well understandable.

Thanx in advance :)

Khalid Ali
03-08-2007, 06:30 PM
try
HttpSession.setMaxInactiveInterval(int interval)
to -1 which means session never expires and then test ur pages...

javula
03-09-2007, 05:35 AM
Well, thanx Khalid, i did that. But still i have the same problem.
In debugging i see that session still holds my attribute, but in javascript-check i get null.
Let me show you my jsp & js code.

part from jsp page:
<%
ModuleStatistics mod2 = (ModuleStatistics) session.getAttribute("baseis2");
ModuleSessions mod1 = (ModuleSessions) session.getAttribute("baseis1");
%>
....
<div id=navigation style="DISPLAY: none">
<a href="#" onclick="check1();">Algorithm 1</a><br>
<a href="#" onclick="check2();">Algorithm 2</a><br>
</div>
js in the <head>:
function check2(){
if (document.mod2 == null){
alert("No streaming performed!");
}
response.sendRedirect("algorithm2.jsp");
}
So, when i click "Algorithm 2" and the streaming has been done, i still get this message that streaming hasn't performed.

javula
03-09-2007, 10:05 AM
sorry if, in the end, this is a javascript problem.. :(