| Author |
reading SESSIONID header.
|
Senthil Kumar
Ranch Hand
Joined: Mar 13, 2006
Posts: 264
|
|
hi, can't we read the session id header using like this. req.getHeader("JSESSIONID"))
|
when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
|
 |
Karthikeyan Varadarajan
Ranch Hand
Joined: Jul 04, 2002
Posts: 98
|
|
Hi Sendhil, Why don't you try it yourself by writing a simple servlet/jsp ?
|
~With Smile<br />VK
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
The session id is not part of Http Headers.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Vikrant Pandit
Ranch Hand
Joined: Mar 27, 2006
Posts: 245
|
|
If cookies are being used for session tracking then you can look for a cookie with the name of JSESSIONID
|
Vikrant Pandit
|
 |
Senthil Kumar
Ranch Hand
Joined: Mar 13, 2006
Posts: 264
|
|
karthi, i've tried it myself and it returns null.But is JSESSIONID not a part of the request header.
|
 |
Senthil Kumar
Ranch Hand
Joined: Mar 13, 2006
Posts: 264
|
|
Vivek, Are you sure a sessionid could be read thru cookies.Bcoz when i run the below code cookie is returned as null. HttpSession sess = req.getSession(false); Cookie[] cook = req.getkookies(); if(cook != null){ for(int i=0;i<cook.length;i++) { if(cook[i].getName().equals("JSESSIONID'")) System.out.println(" Session Id ="+cook[i].getValue()); } } if(sess == null) { System.out.println(" No session exists ..."); sess = req.getSession(); sess.setAttribute("Name","Dravid"); }else { System.out.println("Session prevails .."+sess.getAttribute("Name")); } } }
|
 |
Vikrant Pandit
Ranch Hand
Joined: Mar 27, 2006
Posts: 245
|
|
Hi Senthil, JSESSIONID cookie does gets created on the client browser . If you are using Mozilla then you can view all the cookies conviniently . But the Container is stripping it off the request , before the request reaches reaches the Servlet. Kind of censoring you can say You can use HttpSession.getId() method to view the JSESSIONID
|
 |
Vikrant Pandit
Ranch Hand
Joined: Mar 27, 2006
Posts: 245
|
|
Hi Senthil, I tried it with my piece of code and I did get the JSESSIONID cookie back. So the JSESSIONID cookie does get back to servlet after all ... Sorry for the earlier speculative statement
|
 |
 |
|
|
subject: reading SESSIONID header.
|
|
|