Is this correct to find out the size of the object in session ??am i doing wrong?
i am using HttpSessionAttributeListener interface to get size of the object in session.
private int getAttributeSize(HttpSessionBindingEvent sbe) {
try {
ByteArrayOutputStream bao= new ByteArrayOutputStream();
BufferedOutputStream bos= new BufferedOutputStream(bao);
ObjectOutputStream oos= new ObjectOutputStream(bos);
String attributeName= sbe.getName();
oos.writeObject(sbe.getSession().getAttribute(attributeName));
oos.flush();
int size = bao.size();
return size;
}catch(Exception exp){
return 0;
}
}