How to return Sling model from Servlets and use same model using HTL? | Community
Skip to main content
NaziyaP
May 23, 2019
Solved

How to return Sling model from Servlets and use same model using HTL?

  • May 23, 2019
  • 2 replies
  • 1882 views

Hi All,

I have a Model which I refer in Sling servlet. How do i return this same model from my servlet in my HTML using HTL. I dont' want to do a ajax calls as this model has large data which should be processed at server end only. This Model's data is based on the request , therefore it should be returned from the service only.


Thank you in advance.

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 NaziyaP

I found the solution.
Basically, i wanted to use the sling request with Model, I had set values in my model based ont he particular request , which i did using this.

     @SlingObject

    private SlingHttpServletRequest request;

and initailzed my values in

@PostConstruct

    protected void init()  method based on requests.

2 replies

joerghoh
Adobe Employee
Adobe Employee
May 23, 2019

Can you show us some relevant pieces of this model and and you envision to use it?

Jörg

NaziyaP
NaziyaPAuthorAccepted solution
May 24, 2019

I found the solution.
Basically, i wanted to use the sling request with Model, I had set values in my model based ont he particular request , which i did using this.

     @SlingObject

    private SlingHttpServletRequest request;

and initailzed my values in

@PostConstruct

    protected void init()  method based on requests.