• Post Reply Bookmark Topic Watch Topic
  • New Topic

set cooki servlet and take form javascript  RSS feed

 
Dora Di Donato
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hy,
I set Cooki in the servlet and than I save this in the external file, how i can do? It is possible read the cooki form javascript if they are set with servlet?

thanks

Dora Di Donato
 
Rob Spoor
Sheriff
Posts: 21094
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless the cookie is secure, you can read cookies set on the server with JavaScript. However, that doesn't mean you can write it to just any file. JavaScript can't just access your file system. If it could that would be a huge security hole; I could write a site that would read your system when you visit it. You wouldn't want that, would you?

But here's the main question - why do you need to write the cookies to a file? The browser already does that for you, only in a way it can handle.
 
Dora Di Donato
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my idea is so set cooki like :
this code is in my servlet but i think that is possible to write in the my jsp:
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");

String date = formatter.format(Long.toString(System.currentTimeMillis()));

Cookie cookie_registrazione = new Cookie("Reg_cookie", date);
response.addCookie(cookie_registrazione);

and than I have to the possibility to read by javascript and store in the exernal fyle.
how to is possible?

thanks

Dora Di Donato
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!