• Post Reply Bookmark Topic Watch Topic
  • New Topic

is imported servlet initialized too??  RSS feed

 
Ravissant Markenday
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone!!!

I have a doubt i could use help with.I want to import a servlet class "a" from servlet "A" to servlet "B" using the import statement. So my question is - will the init() in servlet A run???

What I mean is , when i load servlet B, and servlet A's class is imported into servlet B, then along with servlet B, will servlet A be initialized too?

Thanks in advance,

Regards,
Ravissant Markenday
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"import" does absolutely nothing at runtime; it tell the compiler which classes your code refers to, and nothing more. So no; the answer is no.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will not be initialized, because it is not a servlet -just an ordinary Java class-, and the servlet lifecycle does not apply to it. I strongly recommend that you do not misuse servlet classes in this way, but rather separate out any commonly used functionality into its own class, which can then be called from both servlets.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!