Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retreiving url-pattern>from init(...)

 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible for a servlet to learn of its <url-pattern>? I need to be able to do this from init(...).

Any help will be greatly appreciated.

Thank you!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64702
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same servlet could be mapped to many url patterns. So, no there could be no way to determine this during init.

During a request is another matter.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about viewing all of them?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a spec compliant way to do this.
Mapping url-patterns to servlets, filters, etc.. is really the job of the container itself.
If you're using an open source container such as Tomcat, you could probably find the code that holds these mappings fairly easily and tap into that.

Also remember, url-patterns can have wild card characters which would allow an infinte number of possible patterns.

Why would you need to do this?
[ July 21, 2006: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic