Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

how to create a sling servlet which works across sites (with the sites URL), and cross language?

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

28 likes

Total Posts

183 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

28 likes

Total Posts

183 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

07-04-2021

We created some sling servlents following this tutorial: https://aem.redquark.org/2018/10/day-17-working-with-query-builder-api.html.  They make calls to a backend (player database), and pull in some content, and output json for the react page.  e.g. oursite.com/bin/api/oursevlet

 

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?

View Entire Topic

Avatar

Avatar
Validate 1
Level 3
sdouglasmc
Level 3

Likes

22 likes

Total Posts

83 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 3
sdouglasmc
Level 3

Likes

22 likes

Total Posts

83 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back
Ignite 1
Boost 5
Boost 3
View profile
sdouglasmc
Level 3

07-04-2021

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.