GeeCON Prague 2014*
The moose likes Servlets and the fly likes error while setting the session for Enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "error while setting the session for Enumeration " Watch "error while setting the session for Enumeration " New topic
Author

error while setting the session for Enumeration

Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
Hi

I am trying to set a session in one of my class and trying to call in another class

------------------------------code----------------------------
try {
s_Query = ((DfQueryBuilder) m_IDfQueryBuilder).getDocbaseQuery("YOUR_DOCBASE_NAME");
} catch (DfException e) {
e.printStackTrace();
}
getPageContext().getSession().setAttribute("newTest",s_Query);
--------------------------code ----------------------------------

the above piece of code works fine i am able to get teh session s_Query in the 2nd class

myquery =SessionState.getAttribute("newTest").toString();

----------------------------------------------------------------------

But the prblem is when i set a Enumeration variable in the session it gives me an error "Object in session is not serializable"


------------------- my code ---------------------------
IDfEnumeration enumDispAttr = getSearchInfo().getSmartListDefinition().getDisplayAttributes();

getPageContext().getSession().setAttribute("col",enumDispAttr);

--------------------------------------------------------------------------

now in my other class i access as follow

IDfEnumeration enumDispAttr3 = (IDfEnumeration)SessionState.getAttribute("col");
System.out.println("this is before1 session" );
try {

while(enumDispAttr3.hasMoreElements())
{

String strAttr3 = (String) enumDispAttr3.nextElement();
System.out.println("The value of enumstring in the excell class is :"+ strAttr3);

}
}
catch (Exception e)
{
System.out.println("the mistake here is" + e );
}


can you guys tell me how to pass Enumeration in session variables
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

An Enumeration is a 'cursor' type, and if they are now serializable then they're not serializable. You can either pass the parent object (if available) or iterate through the Enumeration, move each element to another data type, and then store that instead.
 
GeeCON Prague 2014
 
subject: error while setting the session for Enumeration