You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2018/06/23 14:24:11 UTC
Experiences from experiments with whiteboard servlets with overlapping paths
I wondered what would happen when registering servlets with overlapping
paths with OSGi web whiteboard.
So I wrote this test application:
https://github.com/steinarb/whiteboard-web-and-api-karaf-demo
It consists of two bundles, each containing a DS component exposing a
Servlet service:
1. webgui which exposes a servlet on /overlap that accepts GET requests
and on "/" returns an HTML page containg a form with a button that
uses (plain) JavaScript to call a rest service on
/overlap/api/counter to get and set a count value in the form
2. webapi which exposes a servlet on /overlap/api/counter that
returns a value of an internal counter in a JSON object on GET
requests, and increments the internal counter and returns the value
on POST requests
So far the behaviour has proved the way I hoped it would be, at least on
apache karaf 4.1.5:
1. With both servlets loaded, clicking on the button increments the
counter
2. When I unload the webapi servlet, clicking on the button no longer
increments the counter, and in the chrome devtools console I see 405
errors, because of requests with unsupported method POST.
Presumably because the webgui servlet on /overlap now picks up
/overlap/api/counter and the webgui servlet only implements the
GET method
3. Reinstalling the webapi servlet returns the increment operation
(starting from 0)
Instructions for bulding and installing the test application is in the
README.