How can I use sling object in a java class(Servlet), I can use that in a jsp file. Can we use that in a java file.
Like this in a Java class:
sling.getService(LoginServiceClient.class)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I belive that you’re trying to get OSGi service (
LoginServiceClient) in some servlet. If your servlet is also managed by the OSGi (so it’s annoted with@Componentannotation), then you can use dependency injection to get any service you want:All these annotations are handled by the Maven SCR plugin.