Scenario:
We have an inhouse application(http://www.a.com) that 'posts' to a different java application's servlet (http://www.b.com/GetAppServlet?token=1234)
In this servlet, I store a parameter sent over into the session.
I display a jsp page (At this time the session is still the same as prior)
Click a button, posts to another servlet (http://www.b.com/SetAppServlet?...) in the same application.... this is creating a new session.
SetServlet:
HttpSession session = request.getSession(true);
session.getAttribute("x") - THIS IS NULL BECAUSE IT'S A DIFF SESSION (VERIFIED BY DISPLAYING SESSIONID)
Kieth Lyman
Greenhorn
Joined: Feb 11, 2009
Posts: 10
posted
0
Would it matter if this first application 'a' does a 'response.sendRedirect' vs setting the action of a form and submitting that form
'
Kieth Lyman wrote:Would it matter if this first application 'a' does a 'response.sendRedirect' vs setting the action of a form and submitting that form
No. They are identical.
Shefali Naik
Greenhorn
Joined: Dec 09, 2009
Posts: 2
posted
0
Kieth Lyman wrote:Hi Pravin,
First Servlet:
HttpSession session = request.getSession( true);
session.setAttribute("x", request.getParameter("x"));
SetServlet:
HttpSession session = request.getSession(true);
session.getAttribute("x") - THIS IS NULL BECAUSE IT'S A DIFF SESSION (VERIFIED BY DISPLAYING SESSIONID)
If I am not mistaken, <a href> tag will not forward the session related data that you created in the previous jsp. Try using c:url JSTL tag instead.
You are mistaken. An anchor link will have no affect on sessions within the same web applications. And, of course, sessions aren't shared across web applications. The use of <c:url> or not is irrelevant.
Kieth Lyman
Greenhorn
Joined: Feb 11, 2009
Posts: 10
posted
0
response.sendRedirect created a new session on the second webapp from the first servlet...that did work. This is different than the 'submit'.
Kieth Lyman wrote:response.sendRedirect created a new session on the second webapp from the first servlet...that did work. This is different than the 'submit'.
Bear, did you mean 'context' is not shared between apps.
Session should not be a problem as it is based on the session id of the client which is passed in a cookie in the request.