Craig R. McClanahan wrote: >On Thu, 29 Aug 2002, Mark R. Diggory wrote: > > > >>Date: Thu, 29 Aug 2002 15:13:21 -0400 >>From: Mark R. Diggory <[EMAIL PROTECTED]> >>Reply-To: Tomcat Users List <[EMAIL PROTECTED]> >>To: Tomcat Users List <[EMAIL PROTECTED]> >>Subject: Re: Is this a Bug in request.getServletPath() ? >> >>Craig R. McClanahan wrote: >> >> >> >>>You seem to be making an unwarranted assumption, that there *is* such a >>>thing as a directory for a context. >>> >>> >>> >>Not neccessarily unwarranted, It is apparent that there is a JNDI >>Context available for resources in Tomcat >> >> > >True, but that's an internal implementation detail, and is not true for >all versions of Tomcat -- only for 4.0 and later. > > Yes, I understand this.
> > >>and that the Servlet API >>specifies that the Implementor is required to provide URLConnections >>(Jar/Http what have you) to the said resources, so that a file could >>reside in a War package or Database or what have you. >> >>Saying that "/" is required in the Servlet Spec. for getResource("/") is >>suggesting that there *is* a concept of a "path" even if the path is a >>"name" resolved in a JNDI Context/SubContext . I'm simply suggesting >>that it would be more powerfull to adopt some simple means to resolve >>resources relative to "Object" making the request as well as absolutely. >> >> >> > >In other words, you want relative paths as arguments to >ServletContext.getResource()? > Yes, relative to whatever the implementation comes up with as the location of that Servlet/JSP (War, database, Filesystem, whatever.). >If so, how do you propose to determine what >object the reference is supposed to be relative *to*? About the only >thing that might make sense is the context-relative part of the request >URI, but it's a pretty simple matter of String concatenation to come up >with the corresponding context-relative path starting with "/". > ie jndi:/localhost/Context/Somewhere/Resource.jsp could easily be in /var/tomcat4/webapps/Context/Somewhere/Resource.jsp or it could be in /var/tomcat4/webapps/Context.war (located at /Context/Somewhere/Resource.jsp) internal to that War file. Doesn't JNDI provide for such Paths as Compound or Composite names? I can't remember which it is right now but I thought that was one of the "Great" powers of JNDI. > > > >>>Such a thing is not required by the >>>servlet spec -- it's perfectly reasonable to run webapps directly from a >>>WAR file, or to represent the static contents in a database, or lots of >>>other interesting possibilities -- and in none of those cases is there a >>>directory to give you the path for. >>> >>> >>> >>For example: In the Java Object model. >> object.getClass().getResource("....") provides a Mechanism to resolve >>both resources relative to the Class/Package of the object and >>absolutely from the classpath root. Now, are Java packages neccessarily >>directory structures? No, they can reside in a Jar File or in the case >>of "Corba/RMI/Object servers what have you", just about any where. But >>when it comes down to it object.getClass().getResource("/foobar.txt") >>means absolutely and object.getClass().getResource("foobar.txt") means >>relatively. Do they not convey this nature even though they may not >>actually be file paths? >> >>As such I still like the idea of the following options at least! >> >>application.getResource("/") resolve to the subcontext of the >>Servlet Context Root >> >>application.getResource("") resolve to the subcontext of the >>Servlet/JSP >> >> >> > >More precisely, to the context-raltive part of the request URI, right? > >There won't necessarily be a static resource that corresponds to every >valid servlet mapping. > Unfortunately, that is true, that can point at a <url-pattern> in a <servlet-mapping> which is different than the <jsp-file> or <servlet-class> in a <servlet> representing of the particular JSP/Servlet.Everything is always based on the Servlet Mapping. It would be helpful to aquire some of the <servlet> specific information (like what is available in <jsp-file> tags in the web.xml file) were available via the Context or Config. Am I missing something? Is there a simple way to get to the information a jsp-file or servlet-class via the ServletContext/ServletConfig? > > >>This would seem logical and much more powerfull, would it not? >> >> > >Perhaps, although the servlet API has lived with context-relative paths >for resources since 2.0 days. At any rate, it's not something that Tomcat >will implement unless the servlet spec is changed -- and to make a >suggestion for that, the appropriate email address is ><[EMAIL PROTECTED]>. > > Yes, that would be an appropriate avenue to discuss api changes. I may continue this there. >Given that Servlet 2.4 is in Proposed Final Draft at the moment, it is >highly unlikely that the expert group would accept a change like this for >2.4 even if they liked the idea, so it would probably go on the plate for >consideration in a subsequent version. > Thanks and Cheers, Mark -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>