Hi All,
I have a requirement to build a latest article component which can be used across the many other site.
So I just thought of creating a servlet which will query all the article under a path(/content/geo/article) which can be controlled by author and send me a JSON response.
Considering the caching startegy I need to pass the parameters as selectors .(Passing as query parameter will not allow me to cache the json until some new article is created)
For Example /bin.article.<limit>.<offset>.json .
Now I need to pass the pagepath lets say /content/geo/article to servlet .Am not able to pass it as selector.Can anyone suggest me a solution for this.
Thanks,
Sambasivaraja.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Sameer,
In such case, we should not register our servlet with fixed path. Map your servlet with selector & resource Type (if resource is one for all article pages). And, when you are trying to call
Here is the code snippet.
@SlingServlet(resourceTypes = "/apps/page/articlePage ",selectors = "article",extensions = "html",methods = "GET")public class DummyServlet extends SlingSafeMethodsServlet {@Overrideprotected void doGet( SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {... }}
This is how you can invoke your servlet and pass
Hi Sameer,
In such case, we should not register our servlet with fixed path. Map your servlet with selector & resource Type (if resource is one for all article pages). And, when you are trying to call
Here is the code snippet.
@SlingServlet(resourceTypes = "/apps/page/articlePage ",selectors = "article",extensions = "html",methods = "GET")public class DummyServlet extends SlingSafeMethodsServlet {@Overrideprotected void doGet( SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {... }}
This is how you can invoke your servlet and pass
Hello Sameer
We shouldn't register our servlet with a set path in this situation. If the resource is a single resource for all article pages, map your servlet with a selector and resource Type. In addition, you use currentPath.selectors> when attempting to invoke a servlet.JSON as the URL for the servlet call.
This is the piece of code.
@SlingServlet(resourceTypes = "/apps/page/articlePage", selectors = "article", extensions = "html", methods = "GET")public class DummyServlet extends SlingSafeMethodsServlet. @Overrideprotected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException...
This is how you can call your servlet and pass other parameters along with the current page's path. Selectors & resource type would be used to resolve the servlet.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies