Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrive serialize files data ERROR

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


<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
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to retrive the details from this file
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What does ObjectInputStream readObject() returns ?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Balu.Now it works
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we do the same deserilization process using useBean properties?
if yes tell me please?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cain i use

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

to deserialized the object.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I change the code as below.
but it prints null
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

null , No error ?

Ok is it not yourfilename.ser ? only ser file name.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic