• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts on following topics

 
Swetha S
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I have the doubts on the following topics

1. Serialization

What is serialization?If serialization is used, Are the session attibutes thread safe automatically?When is this serialization used?Is this used for distributed environment?

2.class Swetha
{
private test;
private marks;
public Swetha() // constructor with default values
{}

// appropriate setters and getters


}
marks before is 50 before
<jsp:useBean id=�SS� class=�com.SCWCD.Swetha>
<jsp:setProperty name=�SS� property=�marks� value=�99�/>
</jsp:useBean>
<%=SS.getTest () %> Marks <%= SS.getMarks() %>

What will be the output? Will I get 50 or 99?

3. about valueUnbound

A session variable say "people" is bound to session scope.
When will valueUnbound method called?
1. When the session is destroyed ( Ilearnt some where that when session is destroyed, first valueUnbound is called & then session Destroyed)
2.When the session is timed out..(This I have doubt..Plzz confirm)


Plzzzz clarify my doubts..and I have still many to get clarified.

Thanks and Regards
Swetha
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) a) serialization = storing an object into a stream
b) There is no relation between serialization and thread safe
c) Yes, Serialization must be used in distributed environment.

2) If the Bean is already there, then the output will be 50.

3) The valueUnbound method will call if the session.removeAttribute("people") is called or the session is distroyed.
 
Swetha S
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi SreeRaj,

ThankYou for your answers. I have another small doubt also.
<jsp:useBean id="employe1" class="..." />
<jsp:getProperty name="employe2" property="..." />

Is there any rule that id and name should be same?

regards
Swetha
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Employee.java


<jsp:useBean id="employe1" class="MyBean.Employee" />

is equal to

MyBean.Employee employe1 = new MyBean.Employee();

So if you want to access the property(name) of the object employe1 you must use employe1.getName().

that means
if want to access the property of employe1 bean, then you must use
<jsp:getProperty name="employe1" property="name" />
not
<jsp:getProperty name="employe2" property="name" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic