Hi All,
I have written sling servlet method with doGet method and trying to write json string onto browser.
I could see this servlet is part of bundle but when i try to access this servlet i am getting 404 error and in the logs it's saying resource is not found.
Servlet Description.
@SlingServlet(paths="/bin/servlets/mySearchServlet", methods = "GET", metatype=true)
public class ConnectToSABA extends org.apache.sling.api.servlets.SlingAllMethodsServlet {
private static final long serialVersionUID = 2598426539166789515L;
@Reference
private SlingRepository repository;
public void bindRepository(SlingRepository repository)
{
this.repository = repository;
}
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException {
try
{
//Encode the submitted form data to JSON
JSONObject myJSON = new JSONObject();
myJSON.put("Name","Kishore");
response.getWriter().write(myJSON.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Please help me in this regard.
Thanks,
Kishore
Solved! Go to Solution.
Views
Replies
Total Likes
configure does not require authentication at http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.auth.SlingAuthenticator
or make user of [1] in servlet & notice the dash prefixing the path - if you don't include the dash that means the path requires authentication.
[1] Property(name = "sling.auth.requirements", value = "-{/bin/servlets/mySearchServlet}")
Views
Replies
Total Likes
Views
Replies
Total Likes
configure does not require authentication at http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.auth.SlingAuthenticator
or make user of [1] in servlet & notice the dash prefixing the path - if you don't include the dash that means the path requires authentication.
[1] Property(name = "sling.auth.requirements", value = "-{/bin/servlets/mySearchServlet}")
Views
Replies
Total Likes
Sham HC wrote...
configure does not require authentication at http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.auth.SlingAuthenticator
or make user of [1] in servlet & notice the dash prefixing the path - if you don't include the dash that means the path requires authentication.
[1] Property(name = "sling.auth.requirements", value = "-{/bin/servlets/mySearchServlet}")
why my servlet is showing as "registered" status in Felix console Components section?
Views
Replies
Total Likes
edubey wrote...
Hi kishore, Ensure that you can see this servlet in osgi in cq5, if you are able see please share a screenshot from osgi. Can you tell, how you are trying to access servlet.
I am trying to access like https://<hostname>:<port>/<servletpath>
PFA.
Views
Replies
Total Likes
If you are following the community article - did you follow every step. You need to deploy the 2nd bundle that contains the Simple JSON JAR file.
Also - can you post a screen shot of the bundle in the felx console. Open it so we can see the details.
Views
Replies
Total Likes
See this community article to learn how to build, deploy and invoke an AEM servlet:
https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Views
Replies
Total Likes
smacdonald2008 wrote...
See this community article to learn how to build, deploy and invoke an AEM servlet:
https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
why my servlet is showing as "registered" status in Felix console Components section?
Views
Replies
Total Likes
Views
Likes
Replies