[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: URI Templates
From:       Mark Thomas <markt () apache ! org>
Date:       2015-08-20 21:42:28
Message-ID: 55D649C4.7070701 () apache ! org
[Download RAW message or body]

On 20/08/2015 16:58, Steffen Heil (Mailinglisten) wrote:
> Hi
> 
> 
> I have several servlets with mappings such as
> /a/*
> /b/*
> /c/*
> And so on.
> 
> One of these mappings was for the old Tomcat 7.0.27 websocket implementation:
> /ws/*
> 
> That worked.
> 
> Now, with the new JSR version in Tomcat 8, I cannot get this to work.
> The problem is, that all of the following paths shall match:
> 
> /ws/a/b
> /ws/a/c
> /ws/d/e
> 
> While these would work using /ws/{one}/{two}, the folloing won't:
> 
> /ws/a/b/c
> /ws/x/Y/z/a
> 
> And I cannot know in advance, how many slashed there are.
> (This is for a framework, not a specific application.)
> 
> Is there any way to match those? Or to add a usual servlet mapping instead of an \
> URI Template? (Prefered prorgrammatically, not per web.xml, not per annotations.)
> 
> While I would prefer a clean solution, I am also fine with one that works in tomcat \
> only (using tomcat private functions).

I see three options.

Option 1

Using ServerContainer.addEndpoint to add the same endpoint multiple
times with different configurations mapped to:
/ws
/ws/{a}
/ws/{a}/{b}
/ws/{a}/{b}/{c}

etc.

If there is a maximum depth that should work. If there isn't then it
will break at the maximum depth you configure +1.


Option 2

Look at the WsFilter implementation [1] and write an alternative filter
of your own that does custom mapping to endpoints and calls
UpgradeUtil.doUpgrade with the right parameters


Option 3
Write a filter that looks at the request and if it should use web socket
redirects to the correct URL and converts the additional pathInfo into
query parameters, puts the values into the session, or something else
along those lines.

HTH,

Mark


[1]
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsFilter.java?view=annotate



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic