permaculture playing cards*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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 liyanage
Ranch Hand

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

Joined: Nov 25, 2008
Posts: 1071
sam liyanage
Ranch Hand

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

Joined: Jan 01, 2009
Posts: 874



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

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

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

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

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

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

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