tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <cos...@eng.sun.com>
Subject Re: SimpleMapper2
Date Thu, 29 Jun 2000 19:05:10 GMT
> The web.xml reader calls addServletMapping in the Context that calls
> addContainer in the CM that calls addContainer in SimpleMapper1 that calls
> addMapping in PrefixMapper that adds a key context_path+servlet_path in the
> hash. I can be wrong but I think you can have a /my/ctx context with a
> /path/servlet/path servlet and a /my/ctx/path context with a /servlet/path
> servlet in the same container. I can't find any code dealing with this but
> from the following example I can figure out an algorithm to precompute that
> context path / longest prefix path.

As I said, the code may have bugs ( like not dealing with this case), but
it can be fixed. The alghoritm is right ( I think ).



> If you have this mappings:
>
> /A/B+/C   --> servlet 1
> /A+/B/C  --> servlet 2
> /A+/B/C/D      --> servlet 3
>
> as keys to the hash you will use only the first string, trivially discarding
> the second one and discarding the third because a requestURI=/A/B/C/D would
> first match /A+/B/C/D and be mapped to the servlet corresponding to /B/C/D
> in the context /A instead of matching /A/B+/C and being mapped to the
> servlet corresponding to /C in the context /A/B with the path info /D. So,
> briefly, all keys prefixed with /A/B/C will be discarded if belonging to a
> context with a path shorter than /A/B.

A trivial fix is to do a check before adding a mapping:
To add CPNew+SPNew:
   For each existing map CP+SP,
         if(  (CP + SP)startsWith( CPNew ))
            remove CP+SP
        if(  CPNew+ SPNew).startsWith( CP ) )
           don't add the new mapping.


> Have I understood you? Is the code really doing anything like this?

No. It's a bug, but I would rather write a TreeMapper than fix SimpleMapper.

Costin


Mime
View raw message