Invoking method inside JSP from Sightly(HTL) | Community
Skip to main content
Level 2
September 16, 2018
Solved

Invoking method inside JSP from Sightly(HTL)

  • September 16, 2018
  • 7 replies
  • 4628 views

Hello Guys,

I have a JSP where all my util methods are written(can't use Java class), I included the JSP in my html(sightly file)  and failed trying to invoke the methods. I can only use JavaScript use API. Any suggestions?

Thanks,

AG

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 arunpatidar

Hi,

Those documents explain how to use JS API instead Java or JSP.

But you can't call JSP methods from HTL or JS API but you can convert JSP code into Java or JS and use inside HTL.

7 replies

joerghoh
Adobe Employee
Adobe Employee
September 16, 2018

No, in HTL you can only access model classes (SlingModels or WcmUse classes), but you cannot invoke methods from JSPs. And btw this really pollutes your application design and makes testing unnecessary hard.

Jörg

edubey
Level 10
September 17, 2018

You can't use JSP method in HTL file.

But you can use JavaScript use API, any specific issue with it?

AG19Author
Level 2
September 17, 2018

Hi edubey,

Please share the syntax or example how I can call using JavaScript use API. I tried but not getting the output.

Thanks.

AG19Author
Level 2
September 17, 2018

Hi Arun,

I gone through all those documentations, nothing helped. None of them has an example of invoking jsp methods in HTL or JavaScript use API.

smacdonald2008
Level 10
September 17, 2018

Here is an artilce that talks about how to use the JS API for HTL -- Creating a Tab layout component for Adobe Experience Manager

NOTE - you cannot use JSP with HTL as ppl on this thread mentioned. You can use JS with HTL - not JSP. The best way is to implement your methods in Java or use Sling Models.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
September 17, 2018

Hi,

Those documents explain how to use JS API instead Java or JSP.

But you can't call JSP methods from HTL or JS API but you can convert JSP code into Java or JS and use inside HTL.

Arun Patidar