How to adapt response object in slingmodel?

Avatar

Avatar

adarshm65812616

Avatar

adarshm65812616

adarshm65812616

07-03-2018

I need to get and set some values in cookie inside the slingModel. I am currently adapting this to SlingHttpServletRequest. Is there any way to inject SlingHttpServletResponse inside the current slingModel.

Replies

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

07-03-2018

Duplicate question:-

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

07-03-2018

See Praveen code in the thread that Kautuk pointed you to.

Avatar

Avatar

adarshm65812616

Avatar

adarshm65812616

adarshm65812616

07-03-2018

In that code snippet they are using only SlingHttpServletRequest  object and is adapted to the SlingHttpServletRequest class.

In my case I need to use both SlingHttpServletRequest and SlingHttpResponse object.

For getting cookie value I'll use the below code

request.setCookie() [SlingHttpServletRequest]

For setting cookie I need to use the below code

response.setCookie() [SlingHttpResponse]

My question is how can I get both the objects in the same slingModel