This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes How to get the url-pattern of a servlet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get the url-pattern of a servlet ?" Watch "How to get the url-pattern of a servlet ?" New topic
Author

How to get the url-pattern of a servlet ?

qzlmk lmklq
Greenhorn

Joined: Mar 22, 2006
Posts: 1
Hi all,

I have defined a servlet-mapping in the web.xml of my webapp:



I want to retrieve the url-pattern of a specific servlet from another one.

For instance, from a method of my_servlet I want to obtain the url-pattern corresponding to my_servlet_bis

I try to use the ServletContext but I don't find a way to do this...

Any idea ?
[ March 22, 2006: Message edited by: qzlmk lmklq ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61054
    
  66

"qzlmk lmklq",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A servlet can have zero, one, or many url-patterns mapped to it.
There are methods in HttpServletRequest for finding out which URL was used for each particular request but the servlet itself has no way of knowing which URL patterns have been mapped to it.


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: How to get the url-pattern of a servlet ?