How Can I call a Service in Servlet
I have created a service called MyService and implemented it, I want to call it in my servlet so how can I do that? please help
I have created a service called MyService and implemented it, I want to call it in my servlet so how can I do that? please help
Hi @ashwinikhaple
Please see below:
public class MyServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
@Reference
private transient MyService myservice;
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
myservice.anything();
}
}
https://sling.apache.org/documentation/the-sling-engine/servlets.html
Hope this helps!
Thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.