This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting cookies on client machine

 
sony rao
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

i need to set cookies on the client machine say for example in C:\Documents and Settings\users\Cookies. how do i do it with the help of servlets. can anyone please guide me. iam completely lost. thanks in advance.
 
Arvind Kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please check the below link this may help you out.
http://www.dickbaldwin.com/java/Java693.htm



Regards,
Aravind
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this will be helpful.

public String getPath()
public void setPath(String path)

These methods get or set the path to which the cookie applies. If you don�t specify a path, the browser returns the cookie only to URLs in or below the directory containing the page that sent the cookie. For example, if the server sent the cookie from http://ecommerce.site.com/toys/specials.html, the browser would send the cookie back when connecting to http://ecommerce.site.com/toys/bikes/beginners.html, but not to http://ecommerce.site.com/cds/classical.html. The setPath method can be used to specify something more general. For example, someCookie.setPath("/") specifies that all pages on the server should receive the cookie. The path specified must include the current page; that is, you may specify a more general path than the default, but not a more specific one. So, for example, a servlet at http://host/store/cust-service/request could specify a path of /store/ (since /store/ includes /store/cust-service/) but not a path of /store/cust-service/returns/ (since this directory does not include /store/cust-service/).
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sony rao:
hello

i need to set cookies on the client machine say for example in C:\Documents and Settings\users\Cookies. how do i do it with the help of servlets. can anyone please guide me. iam completely lost. thanks in advance.


I do not think that we can specify the location where the cookie need to be saved.Using servlet api you can create cookie and send to client , but again you cannot specify any location.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to what Rahul said, cookies are browser-specific, and each browser stores cookies in a different location. The web app has no control over that.

The setPath method mentioned above refers to server paths, not client paths.
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so is there any way to find the location of cookies in client side
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, and you shouldn't need to.
Why would need to know where files are on a client's machine?
 
Ashok Mor
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit, There are diff diff root folder for each user of the system, so there will be separate 'cookie' folder creadted inside root folder of each user, so in these cookie folder there will be index.dat file. so all cookie information will be stored in this file.






Ashok Mor
Ness Technology, Bangalore.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the client/browser.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic