Hello guys,
I want to create a RSS component for every page.
Iam not sure I am thinking the right way.
I want to write a servlet which returns xml of the actual node and give the title, the description and the modify date as RSS-XML to the user. But I don't know how to write one servlet which is called for every page under:
the servlet should be callable as default for every page.
How can I achieve this? Can someone point me in the right direction.
up to now I have the following servlet which renders for a specific resoureType but I am searching for a wildcard or something to call it for every path or specific root path and all of its children.
@SuppressWarnings("serial")
@SlingServlet(resourceTypes = "geometrixx/components/homepage",
selectors = "rss",
extensions = "xml",
methods = "GET",
metatype =true)public class SimpleServlet extends SlingSafeMethodsServlet {
@Reference
private Repository repository;
@Override
protected void doGet(final SlingHttpServletRequest req,
final SlingHttpServletResponse resp) throws ServletException, IOException {resp.setContentType("application/json");
String keys[] = repository.getDescriptorKeys();
JSONObject jsonobject = new JSONObject();
try {jsonobject.put("test", "testvalue");
} catch (JSONException e) {e.printStackTrace();
}resp.getWriter().println(jsonobject.toString());
}
Solved! Go to Solution.
One way to add multiple resources here
@SlingServlet(
resourceTypes = {geometrixx/components/homepage,
geometrixx/components/productpage,
geometrixx/components/articlepage
},
selectors = "rss",
extensions = "xml",
methods = "GET",
metatype =true)
/Brijesh
Okay now i changed the resourceType to my Template resourceType so I can call every page which uses this template with the selector and extension.
Is this a good approach?
Views
Replies
Total Likes
One way to add multiple resources here
@SlingServlet(
resourceTypes = {geometrixx/components/homepage,
geometrixx/components/productpage,
geometrixx/components/articlepage
},
selectors = "rss",
extensions = "xml",
methods = "GET",
metatype =true)
/Brijesh
Can you also tell me the best way to access node properties from a servlet?
Views
Replies
Total Likes
I found a nice article which describes how to register a servlet for every page:
Registering a Servlet for every Page in AEM | TO THE NEW Blog
Views
Replies
Total Likes
Whats your use case - why do you want to do this?
Views
Replies
Total Likes
Hi tim-schwalbe,
Make sure to proxy the request.
Try with embeding jcr:content like [1] which includes jcr:content & it works. To avoid jcr:content in the url create a proxy example Page.feed.jsp with text from [2].
[1] example.com/examplepage/jcr:content.rss.xml
[2] /libs/foundation/components/primary/cq/Page/proxy.jsp
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies