Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why sun people declared config variable as transient in generic class?

 
ranjithkumar.gendhe kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why sun people declared config variable as transient in generic class?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that we know the question is about the GenericServlet class, let's slide it back to the servlet forum. The question is still not entirely clear, though: where did you get the notion of the ServletConfig object being transient or not being transient?
 
ranjithkumar.gendhe kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i noticed this thing in generic servlet class

they declared servletconfig ref variable as transeint in generic servlet. why they are declaring like that.

this class look like

"
public abstract class GenericServlet
implements Servlet, ServletConfig, java.io.Serializable
{

private transient ServletConfig config;

.....
.
.
.
.
}"
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly, Servlets are serialisable and for example can be deployed to multiple nodes in a cluster. The config is specific to a node in the cluster though, so this prevents the config being moved to another node when it should not be, and allows the next node to set its own configuration.
 
ranjithkumar.gendhe kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
k. thanks for your explanation.

i still have some confusing

could you explain with an example

in which cases it will helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic