SlingHttpServletResponse.sendRedirect(resultPage) and displaying data on a different component

Avatar

Avatar

bhavanip6712984

Avatar

bhavanip6712984

bhavanip6712984

03-02-2018

I have a very simple scenario, Where i have a simple component on a template. The component is a simple JSP form with some text fields which is doing a POST to SlingHttpServlet in which i am a calling a External Restful service. The service returns a massive "results" JSON with multiple entities. I am doing a request.setAttribute("searchResults", results); in the servlet.

Then i am doing a sendRedirect(resultPage) to a new page. where there is a component to display the JSON data. when i look for the attribute, it is null.

I tried request.getSession().setAttribute("searchResults", results);  but on redirect i cant still read the attribute in the new Jsp.

i dont want to redo everything in order to display the result information. I just want to display the information.  wjhat would be the simplest way to display the response information.

JSP (post form) ---> Servlet ---> a New Page

Replies

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

03-02-2018

All of our examples are JSP -> Servlet -> results in same JSP.

Does the redirect page work from the servlet?

Avatar

Avatar

bhavanip6712984

Avatar

bhavanip6712984

bhavanip6712984

03-02-2018

The redirect from servlet to new page is working. But i am not able to get the attribute that i set. I am getting a null always.