• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to create a filter for servlets by package?  RSS feed

 
Dan Arbo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a bunch of servlets which require authentication, others don't.

For those which do, I have a filter which checks if the user session is still active or not. If not, it forwards the request to the login page.




When I create a servlet, Eclipse automatically creates an entry for it in web.xml



and I edit it so I that it gets intercepted by the filter.



Sweet, it only takes me 5 seconds. However, I am firmly convinced that the fewer things I have to do, the least likely I am to cock it up. I tend to forget things...

I have searched for a way to filter servlets by the package they are contained in. For example, instead of the <url-pattern>, discriminate by the package in <servlet-class>. I came to the conclusion it probably isn't possible, but maybe somebody is aware of it, or has thought / can think of a hack?

Thanks, Dan
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. They are filtered by pattern.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!