This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

session tracking in jsps using cookies  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am buddy programmer in using servlets and jsps.
Here I need to maintain session tracking of the user logged in to my web site and this session need to be tracked in different jsp pages and servlets.
Try to give me a proper method and code snippets if any.
Thanks a lot in advance,
cheers,
Rajalakshmi.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
via cookies or urlwriting it is done automatically. You just get a HttpSession in the servlet/jsp code, it is handled by the servlet container/ appln server further.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj
The container will automatically track session information for you, all you need to do is tell it to create the session and what data to track. If you are are using cookies (if cookies are enabled on the client) the there is nothing eles you need to do except manipulate the data. If cookies are disabled then you'll need to use url rewriting to add the session id to any urls you are going to pass to the browser. Here are a few of the methods you'll need to look at:
HttpServletRequest.getSession(boolean create)
HttpSession.setAttribute(String name, Object value)
HttpSession.getAttribute(String name)
HttpServletResponse.encodeURL(String url)
Hope that all helps, if you are looking for more concrete examples, post a more specific question and we'll help you out.
Dave
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!