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

Task of a Listener

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Listeners comes into existence when we have the context init parameters that are other than Strings. But if we use only Strings as context init parameters, then we don't see the need for listeners. I'm talking this with reference to ServletContext listeners. Can anyone throw some light on this?

Thanks in advance!
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see what context init parameters have to do with context listeners. The former defines parameters to be used within a context, while the latter is used for executing code when the context is initialized or stopped. They serve different purposes, and are independent of one another.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

When the context init parameters are other than Strings, how can you make that object (in the context init param) be available before any servlets in that web app is processed?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Init parameters can only be strings. There's no way of using anything else.

If you need to make other objects available to all servlets, then you can use an context listener to add them as attributes to the context. But init parameters are the ones defined in web.xml only.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic