Originally posted by danny liu:
User ServletConfig.getServletName method
dan
Thanx for your answers. I agree with you, but I've realized I should have been a little bit more specific. I apologize (to you all).
This is what I want to do: it's a method in a Factory class that, based on a few parameters, builds the URL to access (forward / redirect) a given Servlet (always the same servlet). However, I want it to be "web.xml-independent". That is, that the URL can be built without having to "know" the name assigned to that Servlet inside the web.xml DF.
In order to do what you say, I must be able to access the instance of the servlet that is already in use. Creating a new instance "by hand" (i.e. "new XXXServlet()") and then trying to get ServletConfig out of it will not work since it will be null.
Then, my question should have been as follows:
From a normal class, and being able to access the request (/ session / servlet context): how can I recover (based on the fully-qualified classname) the instance of a Servlet - already present in memory - being managed by the Servlet container, in order to determine its Servlet Name (for that servlet context)?
OR EVEN MORE SIMPLE: given Servlets A and B, how can I obtain A's servlet-name (as specified inside web.xml) from servlet B (at runtime)?
Thanx in advance (again),
Freddy.
[ February 12, 2004: Message edited by: Freddy Villalba ]