• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting different session ids from jsp to servlet

 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all !!!
i have a jsp in my webapps/jsp directory of tomcat5.5. i am creating an httpSession object in my jsp along with html content. the form's action is performed to a servlet which is in my webapps/myapp/classes directory. but that servlet is not able to get the same session id from the jsp.

can u plz tell me how a session can be maintained from a jsp to a servlet in different directory.

thanx
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session created is accessible to servlet without any restriction. session object which is implicit in jsp could be accessed in servlet by request.getSession(); Both these session objects are the same for single browser client and hence the sessionId too.
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello !!!

I know there is no such restrictions for a session to be maintained between jsps and servlets but still i am gettin different session ids.

in my jsp i am just doing
<%
System.out.println(session.getId());
%>

And in my servlet i am doing
HttpSession session=req.getSession();
System.out.println(session.getId());

and i am getting different ids.
and this is all happening in the same browser window.

Thanks For your prompt reply
Hoping for the same.
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I am getting the same Id in jsps and servlets for a single session

I use tomcat 5.5.7
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi !!!
so what do you think is the problem in my case ???
because i have tried so many things but it is still giving me the same prob.

thanx
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!