This will work well for our first site (aka tenant?)
However, if we create a new site, with a new URL, we will want the same servlet, but with the new sites URL, e.g. ourothersite.com/bin/api/ourservlet, but this should pull in different content.
Presumably, we could duplicate the servlet, but it might also be possible to do a redirect or similar behind the scenes? in this case, how would the servlet know which sites content to lookup? We could pass in the URL as a parameter, assuming a servlet in one tenant can access content from another.
To a lesser extent, would translations be an issue, as the servlet would need to know which language content to look for?
I would use the same servlet for easy maintenance (even though you can have a redirect to a different servlet at CDN or dispatcher level)
Same servlet and same query logic based on path (should pass in as a request param)
If you are maintaining multiple sites then you've different farms tied to farm specific rewrites. Therefore, you just need to intercept this servlet request and append the path query param to the servlet
This way, you've one servlet serving to both/more sites and search would be contained to those sites vs global
You can get the URL from the request. You could map those URLs to a property (OSGI configuration for the Servlet) that you can use to determine what data to send back or for processing down a different path. Translations would have to be done regardless - request would have to have something to let the servlet know. You could put the translations into the Database or consider swapping out the database for certain content and use content fragments which are easily translatable. You would need to also allow the path in your dispatcher rules for that domain.