Can i get OSGI service directly from HTL? | Community
Skip to main content
Level 2
May 12, 2017

Can i get OSGI service directly from HTL?

  • May 12, 2017
  • 1 reply
  • 1206 views

Hello,

Suppose

Public interface MessageService{}


@Component
@Service
public class MessageServiceImpl implements MessageService{}

Getting the service in JSP
----------------------------------------
<%
com.example.service.MessageService msgService = sling.getService( com.example.service.MessageService.class);
%>


same way, How can i get service in HTL ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

smacdonald2008
Level 10
May 30, 2017

This is not supported in a HTL component. You need to use Sling Models or WCMUsePojo. See: Scott's Digital Community: Creating an AEM HTML Template Language component that uses the WCMUsePojo class .