• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access a cookie created using Javascript on the client side from a servlet ?

 
Ram Pra
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to access a cookie created on the client using javascript on the server.
When I tried, I don't see the cookie in the HttpRequest object.
Is it possible to access the client side cookies created using javascript on the server using the HttpRequest object.
Thanks in advance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cookies created by JavaScript should be visible in the request. Have you looked at ALL the cookies?
Bill
 
Ram Pra
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have looked at all the cookies in the HTTP header and it doesn't exist.
As we are using a FORM based authentication , we need some information from the login page so we decided to put the information into the cookie using client side javascript which doesn't work.
I also tried to create an intermediate servlet before the j_security_check and I was able to create a cookie and access it from my request after the container's authentication process.But the problem there is that I am unable to use RequestDispatcher, i will have to use sendRedirect which displays the URL on the address bar.
Thanks
 
Ram Pra
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't I see the cookie created by client side javascript on the server.Is there something which I am missing here.
 
Jose Zaleta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I've used JavaScript to create cookies and used them back in a Servlet later on. Are you sure the cookie is being created? You can check the browser's cache, or if you're using Netscape there's a nice utility that can provide this info.
 
Ram Pra
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Everyone !!
Actually I was not setting the path for the cookies created on the client side, wehn I set my path to "/" I could access the cookies on the server without any problems.
Thanks again.
Prashanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic