[img]PostMethod.png[/img]
Hi , I have written a custom servlet which extend SlingAllMethodsServlet. Post request did not resolve by CQ5 server , as we can see in attached image.
My code in servelet class . I am using CQ5.6.1 .
@SlingServlet(
resourceTypes = {"sling/servlet/default"},
methods = {"GET", "POST"},
selectors = {"UserQueryHandlerServlet"},
extensions = {"json"}
)
public class UserQueryHandlerServlet extends SlingAllMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response) throws ServletException,
IOException {
String responseString = processRequest(request,response);
response.getWriter().write(responseString);
}
@Override
protected void doPost(SlingHttpServletRequest request,SlingHttpServletResponse response) throws IOException {
String responseString = processRequest(request,response);
response.getWriter().write(responseString);
}
}
For the doGet() I am getting my Servlet in Adobe Experience Manager Web Console Sling Servlet Resolver but for doPost() getting --com.day.cq.commons.servlets.NonExistingDispatcherServlet (OptingServlet).
And I followed the below mention URL
1- http://sling.apache.org/documentation/the-sling-engine/servlets.html
3-http://labs.sixdimensions.com/blog/dan-klco/2012-12-01/gotcha-sling-servlet-requires-name
4-http://blogs.adobe.com/aaa/tag/sling
Basically my issue doPost() method did not call. I am getting 500 error for doPost method.
I go through all above links. But my problem did not resolve. Please help me please.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
It looks like you missed something from link #3 there about having set name attributes etc for your servlet
which would lead to something in the lines of:
@SlingServlet( label = "User Query Handler Servlet", metatype = true, methods = { "POST", "GET" }, selectors = "UserQueryHandlerServlet", extensions = {"json"}, name="com.myco.UserQueryHandlerServlet") @Properties({ @Property(name = "service.vendor", value = "My Company"), @Property(name = "service.description", value = "Servlet testing user stuff") }) public class UserQueryHandlerServlet extends SlingAllMethodsServlet { }
/Johan
Views
Replies
Total Likes
Hi,
It looks like you missed something from link #3 there about having set name attributes etc for your servlet
which would lead to something in the lines of:
@SlingServlet( label = "User Query Handler Servlet", metatype = true, methods = { "POST", "GET" }, selectors = "UserQueryHandlerServlet", extensions = {"json"}, name="com.myco.UserQueryHandlerServlet") @Properties({ @Property(name = "service.vendor", value = "My Company"), @Property(name = "service.description", value = "Servlet testing user stuff") }) public class UserQueryHandlerServlet extends SlingAllMethodsServlet { }
/Johan
Views
Replies
Total Likes
Hi Ojjis, Thanks for reply. But my problem didn't resolve. Still my facing same issue , doPost() didn't call in my servlet.
this time i did ...
@SlingServlet(
label = "UserQueryHandlerServlet",
metatype = true,
resourceTypes = {"sling/servlet/default"},
methods = {"GET", "POST"},
selectors = {"UserQueryHandlerServlet"},
extensions = {"json"},
name="com.cq.pns.servlet.UserQueryHandlerServlet"
)
@Properties({
@Property(name = "service.vendor", value = "UserQueryPostForm"),
@Property(name = "service.description", value = "Servlet testing Sling")
})
public class UserQueryHandlerServlet extends SlingAllMethodsServlet {
@Override
protected void doPost(SlingHttpServletRequest request,SlingHttpServletResponse response) throws IOException {
String responseString = processRequest(request,response);
response.getWriter().write(responseString);
}
}
Views
Replies
Total Likes
Hi Ojjis,
This issue has been resolved. I just rename the Servlet name :) . I donot know what was the issue, but that has been resolved.
Views
Replies
Total Likes
Ah thats nice to hear, probably just something that was not updated correctly :)
Views
Replies
Total Likes
Views
Likes
Replies