Hi,
You can pass the data from servlet to JSP/Sightly (not HTML).
OSGI as Service
Link:- https://helpx.adobe.com/experience-manager/using/first-osgi.html
// Here we are calling the function on OSGI Service from JSP
<%
com.adobe.cq.KeyService keyService = sling.getService(com.adobe.cq.KeyService.class);
keyService.setKey(10) ;
String ff = keyService.getKey();
%>
Link:- https://helpx.adobe.com/experience-manager/using/sightly_multifield.html
//Sightly fetching information from the OSGI
<div data-sly-use.mbeanObj="com.aem.core.services.TouchMultiComponent">
<p>
<div data-sly-test="${!mbeanObj.mBean}">Add values in Dialog</div>
<div data-sly-test="${mbeanObj.mBean}" data-sly-list.items="${mbeanObj.mBean}">
<h3>${items.dashboard}</h3>
<div data-sly-list.itemsList="${items.items}">
<p><b>page:</b> ${itemsList.page}</p>
<p><b>path:</b> ${itemsList.path}</p>
</div>
</div>
</p>
</div>
Link:- https://helpx.adobe.com/experience-manager/using/using-ajax-requests-display-cq.html
//Ajex
How can we achieve it:-
1. Calling OSGi fucntion directally.
2. AJEX call (doGet/doPost)
3.Using JS to get value.
Can you exactly tell us what would you like to do ?
I hope this would be of some help to you.
Thanks and Regards
Kautuk Sahni