while registering the servlet using path can i use the .*
example
Views
Replies
Total Likes
Hi @HelpTech
1. Can you check this thread if its relevant? -Re: @SlingServletPaths, is there a way to specify ... - Adobe Experience League Community - 577553 It seems /bin/test should cater to /bin/test and /bin/test/abc
2. Otherwise, have you tried like below just to make sure?
@Component(service = Servlet.class, property = {
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths="/bin/test",
"sling.servlet.paths="/bin/test/*"
})
Based on Apache Sling :: Servlets and Scripts it does not seem like there is a wild character or pattern is allowed.
3. Just curious what is the use case to use servlet with varying paths? Trying to see if using sling filter pattern could suffice to the use case or requirement.
Views
Replies
Total Likes
Hi @HelpTech , No, Sling doesn't support wildcards in path.
It is mentioned in the sling documentation as well, that the path attribute accepts only absolute paths. The usage of path based servlets is also discouraged, and it is suggested to use resource based servlets, which provide better security.
Ref : https://sling.apache.org/documentation/the-sling-engine/servlets.html
For your use case - try using request selectors or path suffixes to add some dynamic elements to the URL.
- Regards,
Hi @HelpTech ,
It doesn't support wild character or pattern however you may provide array of path if it is limited an know.
Another approach can be create a filter which support pattern and from there redirect(call) your servlet.
Thanks
Views
Replies
Total Likes
Hi @HelpTech
1. First of all I believe your annotation has an error. You can't have multiple sling.servlet.paths props as far as I know.. So try having only one, and define it based on the specs:
2. Second, specs are not saying we can use wildcards. Which means you have you use other options if you want your servlet to respond to multiple paths. Options already have been mentioned, like URL selectors or extensions. If you wanna go with this approach, please check what sling.servlet.paths.strict property is doing. You might need it, based on you use cases.
3. As it has been already advised here, best practice is to use resource based servlets. Also the specs points out this:
Few useful articles out there on AEM servlets:
Views
Replies
Total Likes
@HelpTech : What is your exact use-case? Do you want this servlet to trigger on multiple paths. If those are your content page paths, you can consider registering your servlet for resource types instead of paths.
You can refer this documentation in-case to see how to register with resource type:-
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies