File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sessions" Watch "Sessions" New topic
Author

Sessions

Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
I know sessions use cookies.
But in my appliaction when i access my appliaction, i found no cookies on my machine...
and if the cookies are disables, will he sessions be managed automatically th' urlrewriting


SCJP 5.0
http://sites.google.com/site/duddlutechnologies/home
Sri Basavanahally
Ranch Hand

Joined: Oct 07, 2003
Posts: 75
Hi Sandeep !
You have to rewrite(in other words it is not automatic) your URLs using encodeURL method in your application. This will ensure session tracking even when cookies are disabled.
-Sri


UP THE IRONS !
Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
hello sri,
Thanks for ur reply....
But i still have two doubts...
1) Since I am using sessions, that means defaulty I am using cookies(is it right to say), so my cookies folder in windows must have some file describing the sessions. But it is not there.
2) If my cookies are disable in a browser, wont i be able to access the session part of my application.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Sandeep
Yes, the default way to manage sessions is through cookies. If cookies are disabled on the client browser then you have to manually call encodeURL() and pass it the URL to write out to the browser. Something like this:

This assumes that out is a valid PrintWriter and resp is a valid HttpServletResponse.
For your first question, there might not be any cookies stored if you never created a session. Did you use HttpServletRequest.getSession(true) to get/create a session? Dont forget that you ahve to get the Session object before writing to the client.
Hope this helps


Dave
Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
Thanks Dave,
But my application always uses sessions, infact one every page i display 2-3 componenets from sessions only. But in cookies folder I deleted all the cookies, and when I run my aplication(browswer), there was no new cookies.
But i noticed one thing that in cookies folder there is a file index.dat, that changes whenever a new session creates(e.g.clicking first time after webserver opens).
So is the index.dat resposible for maianting sessions and if yes then what bout the cookies.
If not then where the cookies are stored?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Sandeep
I dont know what index.dat is, did you try to open it in notepad or another text editor to see what was in it?
As far as the cookies not showing up in your cookies folder or in your temp internet files folder that is most likely because the cookie is set to expire right away so your system never stores them. I would bet that your browser never even writes them to your hard drive. Is there something specific you want to do with the cookies or were you just trying to see them in action?
Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
Thanks Dave...
But our discussion moved to other way..
My question was: There is an application running on a webserver. That application uses sessions(I am storing and retriving some data from session object). When i access this apliaction from other machine say A, then there must be some cookies stored in the cookies folder of machine A.(as cookies is the default method to use sessions). But my problem is that i found no cookies saved on A.
So I wanted to know why the cookies not saving? or if it is saving somewehere else, then where is it(Like index.dat)
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

HttpSession uses transient cookies. They are stored in memory and in in some folder. When the browser is closed the cookie dies because it is transient.
If you want to use persistent cookie uwe the Cookie class. Refere the docs for more info.


Groovy
Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
Dear Pradeep,
Thanks a lot for ur answer. I never heared bout the transient cookies. Can I get more bout this.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://edocs.bea.com/wls/docs70/servlet/progtasks.html#143245
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sessions