hsperhar
asked on
How to forward the session entries through href
Hi Friends,
I'm developing a site in jsp and it passes the session and its attributes when I go to any JSP page through servlet. But when I go to one JSP page to another via href="<% response.encodeURL("my URL?someParameter=1")%>"> ,it takes me there but losses the session entries and there shows me null session.
I'm in situation where I need to use href-links to move to another JSP page. My question is how can I use RequestDispatcher or anything else in href link through which my next JSP page could get the attributes of the session and do not show the sessionAttributes as null.
I'm developing a site in jsp and it passes the session and its attributes when I go to any JSP page through servlet. But when I go to one JSP page to another via href="<% response.encodeURL("my URL?someParameter=1")%>"> ,it takes me there but losses the session entries and there shows me null session.
I'm in situation where I need to use href-links to move to another JSP page. My question is how can I use RequestDispatcher or anything else in href link through which my next JSP page could get the attributes of the session and do not show the sessionAttributes as null.
ASKER
Thanks for reply, this didn't work. I look further into this. Let me explain the problem in more detail:
I am creating HTTP Session in servlet which redirect to one JSP page(lets call-JSP1) with the help of RequestDispatch method. After that ,even before requesting for solution, through href I am redirecting to JSP1,but this time it gets different page in its one table with the help of JSP include page tag.Lets, for instance, call this new JSP1 page as JSP2
Ok, when I check the session IDs Servlet and JSP1 shares the same session ID but JSP2 does not,why?
In JSP2, since session is new so I am not getting the user information & cannot use session to collect that. I donot want to pass hidden parameters to passon the user information. What exactly , I am doing wrong due to which JSP2 is not getting the session of JSP1?
I am creating HTTP Session in servlet which redirect to one JSP page(lets call-JSP1) with the help of RequestDispatch method. After that ,even before requesting for solution, through href I am redirecting to JSP1,but this time it gets different page in its one table with the help of JSP include page tag.Lets, for instance, call this new JSP1 page as JSP2
Ok, when I check the session IDs Servlet and JSP1 shares the same session ID but JSP2 does not,why?
In JSP2, since session is new so I am not getting the user information & cannot use session to collect that. I donot want to pass hidden parameters to passon the user information. What exactly , I am doing wrong due to which JSP2 is not getting the session of JSP1?
ASKER
I'm using response.encodeURL method to go from JSP1 to JSP2. What exact steps I can use in href so that it can pass the same session to the next page?
>Ok, when I check the session IDs Servlet and JSP1 shares the same session ID but JSP2 does not,why?
JSP2 should have same session. I don't know why you are having this problem. Please reduce your code to the minimum that demonstrates the problem and post it here. Maybe we will be able to debug.
JSP2 should have same session. I don't know why you are having this problem. Please reduce your code to the minimum that demonstrates the problem and post it here. Maybe we will be able to debug.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window