• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In which package should be a Listener

 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello..
I am using MVC for my web-app.
I have two packages:
(1)myPackage.web : Package for Controller classes (Servlets)
(2)myPackage.model : Package for Model classes (Helper classes)

Now I want to add a ServletContextListener class in my app.
In which package should I put it?

Thanks in advance..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it part of the model?
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Is it part of the model?


The Listener is used to get Data Source Name from context-init-parameters and to get a Connection using that Data Source Name, which can be used by Model classes afterwards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your model should be compeltely independent of the user interface. In other words, if you chose to put a Swing UI on your application, would the listener class still be a useful part of the model?
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, Bear
I didn't get your answer..
Can you elaborate it?
Thanks in advance...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Your model should be completely independent of the user interface. ...


In your case the user interface (UI) is a servlet application.
ServletListeners are part of the servlet spec and part of the javax.servlet. API.

Would your model package be independent of the UI if it contained classes that need to import javax.servlet classes?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic