Hi, I believe that if you access it via a mapping, that's how you will see its location. So if you go to the real location in the browser, i.e. /Jaxp/JSPTransformExample.jsp, you will get that location instead of the mapped one.
In general, you are not guaranteed to have access to the server's mappings, much less the ability to introspect them as you would like in this use case. A better approach may be to use getResource() and/or getResourceAsStream(), as that would give you the resource and would work in a WAR, which the getRealPath() approach won't. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Mark R. Diggory [mailto:[EMAIL PROTECTED]] >Sent: Thursday, August 29, 2002 9:53 AM >To: Tomcat Users List >Subject: Is this a Bug in request.getServletPath() ? > >I'm trying to get a file in the filesystem relative to the location of a >JSP Page. At first Blush the following would seem appropriate: > ><% >String jsp_location = application.getRealPath(request.getServletPath()); > >String relative = jsp_location.substring(0,jsp_location.lastIndexOf("/")); > >... get the resource using this path ... > >%> > >however, when one uses a servlet mapping on a JSP Page like below. > > <servlet> > <servlet-name>JSPTestMap</servlet-name> > <jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file> > </servlet> > <servlet-mapping> > <servlet-name>JSPTestMap</servlet-name> > <url-pattern>/Jaxp/MapExample.jsp</url-pattern> > </servlet-mapping> > >request.getServletPath() returns > ><url-pattern>/Jaxp/MapExample.jsp</url-pattern> > >and not > ><jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file> > >is there any way I can get hold of the original real location of the JSP >Page I'm working in and have it also work with servlet-mappings? > >-Mark Diggory > > > >-- >To unsubscribe, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]>
This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you.
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>