Getting 404 Error while accessing sling servlet
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