This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener+Servlet is it possible?  RSS feed

 
Adithya Menon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a class at the same time be a Servlet and a Listener.If so how they should be described in the DD.
like
public class ManageSession extends HttpServlet implements HttpSessionListener{//code here}
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible, but why would you do so? Also note that you then need to be careful about how things are initialized in that class, since there will be more than just a single instance of it.

You'd declare it same way you'd declare any other servlet and any other listener.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was post here a few months ago by someone who tried to do just that and had no end of troubles. It's simply a bad idea. Assuptions about one-half of the class were incrorrect for another. There is no good reason to try and do this.
 
Adithya Menon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for troubling.I got hold of ServletContext directy from HttpSession.
Thanks for the reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!