Win a copy of Hello World this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

how to get a seesion object without using cookie?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as titles
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get a session (using HttpServletRequest.getSession()) whether cookies are enabled or not. (But, if cookies are not enabled, you'll get a new session each time!)
If you have cookies enabled, or are using SSL, then the container is able to recognise requests that belong to the same session. If not, then you need to help it along, by passing the session ID along in the URL.
You can get the session ID (as a string) by calling getId() on the session. You then add a parameter "jsessionid" to the URL with the ID as its value, eg:
http://localhost:8080/timd/servlet/SessionReader;jsessionid=1163B45839073195F84284 68C779C045
It's all in the Servlet spec.


[This message has been edited by Tim Duncan (edited November 27, 2001).]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Al the test for sessionid, if session cookies are enabled etc. can happen in the background. Everywhere in your servlet or on your jsp page that you need to put a url, call HttpServletResponse.encodeURL(String url) and it will return a properly encoded url if and only if it is necessary to use this for session tracking.

------------------
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!