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

retrive serialize files data ERROR

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
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
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
sameera liyanage
Ranch Hand

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

Joined: Jan 01, 2009
Posts: 874



What does ObjectInputStream readObject() returns ?
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
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.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
thanks Balu.Now it works
sameera liyanage
Ranch Hand

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

Joined: Nov 25, 2008
Posts: 643
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.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
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.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
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
 
Similar Threads
save my bean class in wrong place
how to use beanName
deserilize using usebean
jsp:getProperty gives null
java.io.NotSerializableException: