aspose file tools*
The moose likes Servlets and the fly likes Retreiving url-pattern>from init(...) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Retreiving url-pattern>from init(...)" Watch "Retreiving url-pattern>from init(...)" New topic
Author

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

Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
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

Joined: Jan 10, 2002
Posts: 61187
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
What about viewing all of them?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retreiving url-pattern>from init(...)