Calling USE API script from JSP | Community
Skip to main content
Level 2
July 19, 2021
Solved

Calling USE API script from JSP

  • July 19, 2021
  • 2 replies
  • 1904 views

What is the alternative for the data-sly-use attribute in JSP. Is there any other way to call use api scripts from a .jsp file?

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

@premib As per my knowledge you need to write the whole logic into the JSP file itself and inside the scriptlet tags.

ex.

 

<% String propertyName = properties.get("propertyName", String.class); %>

 

P.S.  It better to use Sightly /HTL based component over JSP based component.

 

2 replies

Suraj_Kamdi
Community Advisor
Suraj_KamdiCommunity AdvisorAccepted solution
Community Advisor
July 19, 2021

@premib As per my knowledge you need to write the whole logic into the JSP file itself and inside the scriptlet tags.

ex.

 

<% String propertyName = properties.get("propertyName", String.class); %>

 

P.S.  It better to use Sightly /HTL based component over JSP based component.

 

PremIBAuthor
Level 2
July 19, 2021

@suraj_kamdiI am trying to overlay the richtext widget from /libs/cq/gui/components/authoring/dialog/richtext/render.jsp in /apps then call a javascript use api script from that jsp file. Here, I do not have an option to use HTL to directly call the script with data-sly-use, because i am not sure about changing the jsp script to HTL. if you can refer me to an updated HTL version of the RichText widget, that would be enough for me. Also, I cannot move my javascript use api script's logic to jsp either, it is already referenced by multiple HTL files.

Shubham_borole
Community Advisor
Community Advisor
July 19, 2021

Hi,

 

What is the use case here? Please see https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/calling-custom-utility-methods-in-jsp/qaq-p/188661 if that is useful.

Ideally if you have backend implementation already as a Model try to use HTL. Keep the backend implementation logic in service components so that if you have to use jsp, it can be called within jsp.

Another way (may be not ideal) use a .html file to use the data-sly-use attribute. Use or include this HTL file within the ultimate jsp where you are looking to use the data-sly-use attribute