Expand my Community achievements bar.

SOLVED

Invoking method inside JSP from Sightly(HTL)

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

7 Replies

Avatar

Employee Advisor

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

Avatar

Level 10

You can't use JSP method in HTL file.

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

Avatar

Level 2

Hi edubey,

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

Thanks.

Avatar

Level 2

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.

Avatar

Level 10

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.

Avatar

Correct answer by
Community Advisor

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