tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42157] - URLs returned by ServletContext.getResource() cannot resolve, directories cannot be browsed...
Date Thu, 19 Apr 2007 10:24:47 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42157>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42157





------- Additional Comments From rui.damas@gmail.com  2007-04-19 03:24 -------
Ok... i have taken a look at the source code of version 5.5.23 to better
understand why this behaviour...

The URL is constructed at ApplicationContext.getResource() at lines 501-503:

return new URL
  ("jndi", "", 0, getJNDIUri(hostName, fullPath),
  new DirContextURLStreamHandler(resources));

Where the hostName is part of the path.
Why is the hostName at the host name parameter instead of ""?...
My only guess is that the host name parameter could possibly be 
be used to represent jndi resources on other machines and hostName
is used to represent the virtual host, is that why?

But thats not really the problem...
The path gets built using getJNDIUri(hostName, fullPath), lines 967-972:

private static String getJNDIUri(String hostName, String path) {
  if (!path.startsWith("/"))
    return "/" + hostName + "/" + path;
  else
    return "/" + hostName + path;
}

Here is where the URL gets the TWO SHASHES...
I see you do check the path... but the hostName is not checked
so the second slash must come from the hostName,
obviously this cannot be solved here because the URL handlers
do understand the path with two slashes.

I started to track where the host name comes from and reached
StandartHost class somewhere arround:
public ObjectName preRegister(MBeanServer server, ObjectName oname ) 
public ObjectName createObjectName(String domain, ObjectName parent)
public void setName(String name) {
public String getName() {

... Why does the (virtual) hostName comes with a slash?
is it supposed to be like this?

I bumped into this when codding a servlet that uses XSLT transformations,
which uses URI's to resolve resources, because URI.resolve will alter
the two slashes to one, the URLConnection will not work.

This feels ridiculous, is it suposed to not be able use XSLT transformations?
Does this has another solution?

I could use the getRealPath() but that only works for file://, and will
disable the possibility of storing the webapp in a ".war" file.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message