If you are running in a servlet container supporting the 2.2 spec (such as
Tomcat), the closest equivalent to what you are asking is the
ServletConfig.getServletName() call, which was added in 2.2.  Prior versions of
the spec provide no mechanism to do this.

Craig McClanahan


William Crawford wrote:

> I don't believe this is possible--in fact, I don't think that all servers
> even support servlet mapping, although they should. It's certainly possible
> to invoke a servlet by class name under some platforms, so no mapped name
> will exist.
>
> You could try calling HttpServletRequest.getServletPath() and using some
> portion of the data retrieved there. For instance, if the servlet is
> invoked by calling /servlet/{mapped name} you could strip off the /servlet/
> and have the mapped name.
>
> Of course, this will fail if you use servlet aliases. If you map *.mml to
> MyMarkupServlet, then the getServletPath() return value will probably be
> something like /path/file.mml, which isn't much good. Same to mapping
> MyServlet to a fixed URI, although you could probably use that URI (or some
> permutation) as your identifier.
>
> Let us know how you do it.
>
> Will
>
> At 03:03 PM 6/28/2000 -0700, you wrote:
> >Could someone enlighten me how to determined the mapped name of
> >a servlet?  I'm referring to the name of the servlet as mapped by the
> >zone property:
> >
> >         servlet.{mapped name}.code=some.servlet.class
> >
> >I would like to use this bit of info as a prefix for form input elements in
> >a specialized mail form servlet I'm writing.   I've looked through the
> >servlet classes and haven't found the obvious answer.
>
> ---
> William Crawford                                        + 01 617 577 7844
> Invantage, Inc                                            [EMAIL PROTECTED]
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to