aspose file tools*
The moose likes JSP and the fly likes retrive serialize files data ERROR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "retrive serialize files data ERROR" Watch "retrive serialize files data ERROR" New topic
Author

retrive serialize files data ERROR

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
first i serialize my file using this code .it works



then i try to retrive data using following code .But it didn't working

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



<jsp:useBean id="ana" type="my.Mybean" beanName="WEB-INF/classes/aruna.ser" scope="session">


You got to un-serialize back to object before you can use it.

Check out some tutorial on Serialization before trying non-meaningful things
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
how to retrive the details from this file
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



What does ObjectInputStream readObject() returns ?
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
I also have same problem.for which to assign the oos.readObject();
some tutorials says use this

PersistentTime p=oos.readObject();
but it is not working
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874




PersistentTime is user defined class in the example and it is just an example. Cast the returned Object to your Class object.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
thanks Balu.Now it works
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
can we do the same deserilization process using useBean properties?
if yes tell me please?
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
cain i use

<jsp:useBean id="xxxxxxxxxxx"
type="yyyyyyyyyyyyyyy"
beanName="zzzzzzzzzzzzzzzzzz"
scope="session" />

to deserialized the object.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



jsp:useBean defines a bean in the specified scope and which can be used later. It does not relate to Serialization at all. You got to serialize and deseriliaze using the same ObjectInputStream and ObjectOutputStream only.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
in some book i found that beanName property of

<jsp:useBean id="xxxxxxxxxxx"
type="yyyyyyyyyyyyyyy"
beanName="zzzzzzzzzzzzzzzzzz"
scope="session" />

use for serilize the object;

"
The beanName attribute specifies the name of a bean as expected by the instantiate()
method of the java.beans.Beans class. For this reason, beanName can
refer either to a serialized bean or to the name of a class whose instance is to be created.
"
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Aruna,

Oh yeah.. i got it here in the specification too.


beanName="{package.class | <%= expression %>}" type="package.class"

Instantiates a Bean from either a class or a serialized template, using the java.beans.Beans.instantiate method, and gives the Bean the type specified in type. The Beans.instantiate method checks whether a name represents a class or a serialized template. If the Bean is serialized, Beans.instantiate reads the serialized form (with a name like package.class.ser) using a class loader. For more information, see the JavaBeans API Specification.


So it should work with "package.class.ser" , in your case it is my.Mybean.ser. try this.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
I change the code as below.
but it prints null
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


null , No error ?

Ok is it not yourfilename.ser ? only ser file name.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrive serialize files data ERROR