Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification

 
KasiMurugan Ramasamy
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

i have understood as following for init(ServletConfig),

We adviced to not override the above method. My understanding is if we override the method we have to explicitly store the servletconfig of parameter to instance variable config. This is correct.

The same reason is applicable for, why we are not adviced to provide the constructor accepts serveltconfig as arguments.

Please comments on my opinion. And also add if have any valid points.
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why we are not adviced to provide the constructor accepts serveltconfig as arguments


Where did you get serveltconfig object to pass as an argument to constructor.
 
KasiMurugan Ramasamy
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear vidyasagar,

Our servlet is instantiated by container. After the constructor without arugment execution, the container creates the servletConfig for the servlet. Then it calls the init(servletconfig). My question is, assume that the servletconfig object is created before calling the servlet's constructor, that time we can have the servletconfig object and pass the same config object into constructor. That time we need to explicitly specify the servletconfig assigned to instance variable(sometime developer forget to set into instance variable, it will work until the servlet has no init params). This is the reason spec enforce us to use constructor without arugs
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope but not sure.

Sun wants to differentiate between object creation and providing that object as a status of servlet.So they come with constructor and init method.

Correct me if i am wrong
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The J2EE is framework. The Framework provide the API contarcts not implementations. You should follow the rules of the framework, to implement the framework correctly.

Thanks
 
KasiMurugan Ramasamy
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear vidyasagar,

I agree with you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic