Sharing session information between JSPs when
using MMapSessionManager in iWS
Issue:20000825-2 Product:iPlanet WS Created:08/25/2000 Version:4.1
Last Updated:08/25/2000 OS:All
Does this article answer your question?
Please let us know!
Problem:
When working with session objects in Java Server Pages(JSPs), I encounter problems when I use
MMapSessionManager . For example, I have written the following sample JSPs:
one.jsp
<%@ page import="com.ivendor.ui.*" %>
<jsp:useBean id='simpleBean' scope='session'
class='com.ivendor.ui.SimpleBean' type='com.ivendor.ui.SimpleBean'/>
<%
simpleBean.setMessage("Hello World"

;
response.sendRedirect("two.jsp"

;
%>
---------------------------------------------------------------------------------------------------
two.jsp
<%@ page import="com.ivendor.ui.*" %>
<jsp:useBean id='simpleBean' scope='session'
class='com.ivendor.ui.SimpleBean' type='com.ivendor.ui.SimpleBean'/>
<html>
<BODY>
<%
out.println("inside two.jsp<br>"

;
out.println("Value of Message:" + simpleBean.getMessage());
%>
</BODY>
</html>
---------------------------------------------------------------------------------------------------
SimpleBean.java
package com.ivendor.ui;
import java.lang.*;
import java.io.Serializable;
public class SimpleBean implements Serializable
{
public String message;
public SimpleBean()
{
;
}
public void setMessage(String str)
{
message = str;
}
public String getMessage()
{
return message;
}
}
---------------------------------------------------------------------------------------------------
When testing the JSPs, the output from two.jsp is as follows:
inside two.jsp
Value of Message:null
The "null" value for the output on the second line indicates that the message set in one.jsp is not
carried over to two.jsp, which is contrary to the expected behavior of the JSPs when the scope is
set to "session." However, the sample JSPs work properly with SimpleSessionManager.
Workaround:
To work around this problem, manually re-register the bean object to the session object after changing
the bean's properties, using the following example:
one.jsp (modified)
<jsp:useBean id='simpleBean' scope='session' class='com.ivendor.ui.SimpleBean'
type='com.ivendor.ui.SimpleBean'/>
<%
simpleBean.setMessage("Hello World"

;
session.setAttribute("simpleBean",simpleBean);//re-register the bean
response.sendRedirect("two.jsp"

;
%>