This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
this servlet is registered and enabled and active all good checked from below
http://localhost:4502/content/we-retail/AmitHomePage.amit.ttt
http://localhost:4502/content/we-retail/AmitHomePage/jcr:content.amit.ttt
http://localhost:4502/content/we-retail/AmitHomePage/_jcr_content.amit.ttt
nothing is working .
is there any configuration or anything i missing ?
nothing in logs as well.
Views
Replies
Total Likes
Can you verify your servlet here and see if your servlet is getting registered for the given resourceType :
http://localhost:4502/system/console/servletresolver?url=yourResourceType&method=GET
Hi @AdobeID24 ,
Here is a working code snippet :
@Component(service = { Servlet.class }, immediate = true)
@SlingServletResourceTypes(
resourceTypes = "anf-code-challenge/components/title",
methods = HttpConstants.METHOD_GET,
extensions = "ext",
selectors = "milind"
)
public class ResourceTypeServlet extends SlingSafeMethodsServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(final SlingHttpServletRequest req,
final SlingHttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().write("servlet is called");
}
}
Thanks,
Milind
The methods inside the resource type servlet are case-sensitive.
Please use "GET"[uppercase] instead of "get"[lowercase] or use the
HttpConstants.METHOD_GET
as I used in the reference snippet in the below comment.
Post build , http://localhost:4502/content/we-retail/AmitHomePage/jcr:content.amit.ttt should resolve to your servlet.
Thanks,
Milind
I followed the same .
https://sourcedcode.com/blog/aem/registering-slingservletpaths-component-property-type
Thanks for the help @milind_bachani i ll try that get thing which you asked .
make Methods "GET" and it should work
@Component(service = { Servlet.class })
@SlingServletResourceTypes(
resourceTypes="project/components/structure/page",
methods= "GET",
extensions="txt",
selectors="amit")
public class SimpleServlet1 extends SlingSafeMethodsServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(final SlingHttpServletRequest req,
final SlingHttpServletResponse resp) throws ServletException, IOException {
final Resource resource = req.getResource();
resp.setContentType("text/plain");
resp.getWriter().write("Title = amit");
}
}
try- http://localhost:4502/content/project/us/en/index/jcr:content.amit.txt
You can check your servlet registration and mapping here http://localhost:4502/system/console/servletresolver
Not working ..
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies