Hi
I am trying to store a object in session in SlingAllMethodsServlet and retrieve it back in CQ JSP. When doing so i get the error as below. Attached the full stacktrace.
This error appears random. Couldn't find the actual scenario when it occurs to.
Caused by: java.lang.IllegalStateException: Response already committed: unable to send session in cookies
at com.day.j2ee.servletengine.ServletHandlerImpl.getSession(ServletHandlerImpl.java:1072)
at com.day.j2ee.servletengine.RequestImpl.getSession(RequestImpl.java:525)
at com.day.j2ee.servletengine.RequestImpl.getSession(RequestImpl.java:532)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:235)
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:235)
Solved! Go to Solution.
Views
Replies
Total Likes
The message "Response already committed" this mean the http response object already got "flush" so that part of the response is already transmitted to the client and thus you cannot set anymore cookies as this is part of the header in the http protocol.
You have to check in your template/components if there are
Views
Replies
Total Likes
The message "Response already committed" this mean the http response object already got "flush" so that part of the response is already transmitted to the client and thus you cannot set anymore cookies as this is part of the header in the http protocol.
You have to check in your template/components if there are
Views
Replies
Total Likes
Can you please post your code so we can better understand what you are trying to do.
Views
Replies
Total Likes
smacdonald2008 wrote...
Can you please post your code so we can better understand what you are trying to do.
Need help on this. Still the problem exists.
Views
Replies
Total Likes
In Servlet
@SlingServlet(resourceTypes = "/apps/geometrixx/full/download", methods = {"POST" })
public class DownloadRequestServlet extends SlingAllMethodsServlet {
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
//Some Logic to get the List Object.
String nextPage="/content/geometrixx/samplejsp.html";
request.getSession().setAttribute("list", list);
response.sendRedirect(nextPage);
}
}
JSP code
i try to the list object which was set in session.
List list = (List)request.getSession().getAttribute("list");
I get error in the above line.
Views
Replies
Total Likes
I am able to retrieve the session object in CQ5.6 and 5.5
If i had the below code in CQ JSP:
<% out.println(request.getSession()); %>
The output is:
accessTime: Mon Oct 28 17:36:44 IST 2013 creationTime: Mon Oct 28 17:36:44 IST 2013 isNew: true lifeTime: 600 seconds sessionId: c8367fed-1a56-4984-9804-13cc580f8e24
But in CQ5.6.1 i m getting the exception, attached the error log for reference
Views
Replies
Total Likes
I m getting the below exception if i access the session object in CQ JSP
Caused by: java.lang.IllegalStateException: Response already committed: unable to send session in cookies
Code:
request.getSession(); results in the above error. Cant i access session object in CQ Jsps?
Views
Replies
Total Likes
hi rrakesh,
i have the same problem in one of our components. i tried to reproduce it with a simple jsp including the following code:
<h2>Session info</h2> <p><%out.println(request.getSession());%></p> <h2>Read attribute from session</h2> <p>Attribute value: <%=request.getSession().getAttribute("foo")%></p> <h2>Write attribute to session</h2> <%request.getSession().setAttribute("foo", new Random().nextInt());%>
This seems to work on 5.5, 5.6 AND 5.6.1 for me. I'm not sure if i missed something here. On the same systems, I get the IllegalStateException for other components using similar code.
Views
Replies
Total Likes
Views
Likes
Replies