Call AEM Servlet based on asset path
Hello All,
Any thoughts on how can we call a servlet based on the asset path, say /content/dam/cms/assetpath.
If I want to load a servlet if we hit any asset under this path.
Thanks,
Sateesh K.
Hello All,
Any thoughts on how can we call a servlet based on the asset path, say /content/dam/cms/assetpath.
If I want to load a servlet if we hit any asset under this path.
Thanks,
Sateesh K.
Technically you can register to any resource, but you cannot register a servlet by resourceType and specify the filter on it, instead, you could use a Sling servlet Filter, I would recommend exploring the Sling Filter first. Answering your question, the resource type to register an asset is "dam/Asset".
Another option could be to use a Workflow + WF Launcher to make sure a workflow is executed only under that asset.
Just for reference, this is how you will register the servlet for all the resources which are assets:
(service = { Servlet.class })
@SlingServletResourceTypes(
resourceTypes="dam/Asset",
methods=HttpConstants.METHOD_GET,
extensions="txt")
@ServiceDescription("Simple Demo Servlet")
public class MyServlet extends SlingSafeMethodsServlet {
..
..
..Then, you will invoke the servlet like this:
http://localhost:4502/content/dam/myasset.jpg.txt
Hope it helps
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.