Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create dynamically contexts for com.sun.net.httpserver.HttpServer (Java)

Tags:

I need to handle HTTP requests using com.sun.net.httpserver.HttpServer which requests are triggered by the following URL schema:

http://somehost:9000/<var>/<service>

<var> is a parameter which is passed to the <service>

<service> is a predefined service that the server provides

The problem is that the context path is not known at compile time (because of the <var>) so I can not just call createContext(String path, HttpHandler handler). How can I bind this kind of 'dynamic' context to a specific HttpHandler instance?