Expand my Community achievements bar.

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

Avatar

Level 2

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

2 Replies

Avatar

Level 10

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

Does the redirect page work from the servlet?

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.