I think that this approach is very close to what you want. Instead
of lastIndexOf("/") you could do lastIndexOf (or indexOf) getServletName.
Another alternative would be to use lastIndexOf(getPathInfo()) on the
request URI.
As to why the methods return what they do, its because the spec says
so.
Randy
> -----Original Message-----
> From: Mark B. Indictor [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 2:03 PM
> To: 'Tomcat Users List'
> Subject: RE: REPOST: Please HELP!: URL Mapping Problems in servlet
>
>
> I appreciate the help, but this still does not solve my problem.
>
> You see, I need to handle URLs of the following forms:
>
> http://hostname/context/servlet/xxx
>
> as well as:
>
> http://hostname/context/servlet
>
>
> With your suggestion, I would be truncating these to:
>
> http://hostname/context/servlet
>
> and
>
> http://hostname/context
>
> Respectively.
>
> The first behavior is desirable, the second is not!
>
> What I do not understand is why Apache and Tomcat conspire hide the
> 'context' element of the URL. I either need to find a way to
> isolate and
> retrieve the full path to the servlet (/context/servlet) or I
> need to find a
> way to set up Apache and Tomcat to recognize a URL that does
> not contain a
> context component (/servlet).
>
> Why does getServletPath() not return the whole path to the servlet,
> including its context, if this information is, in fact,
> required to access
> the servlet with a URL!?
>
> Any suggestions?
>
> Thanks!
>
> - mbi
> ======================================================
> Mark Indictor -- Site2 Corporation
> [EMAIL PROTECTED]
> <http://www.site2.com>
> Phone:(310)451-3472 FAX:(240)220-6341
> http://keyserver.pgp.com/pks/lookup?op=get&search=0x8959F966
> ======================================================
>
>
>
>
>
> -----Original Message-----
> From: Cox, Charlie [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 27, 2002 10:44 AM
> To: 'Tomcat Users List'
> Subject: RE: REPOST: Please HELP!: URL Mapping Problems in servlet
>
>
> I don't think there is a function to get the full request
> path without the
> final page/servlet name.
>
> This should get what you need:
> req.getRequestURI().substring(0,req.getRequestURI().lastIndexOf("/"))
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>