aspose file tools*
The moose likes Servlets and the fly likes How to access a cookie created using Javascript  on the client side from a servlet ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to access a cookie created using Javascript  on the client side from a servlet ?" Watch "How to access a cookie created using Javascript  on the client side from a servlet ?" New topic
Author

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

Ram Pra
Ranch Hand

Joined: Feb 06, 2001
Posts: 37
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

Joined: Mar 22, 2000
Posts: 12823
    
    5
Cookies created by JavaScript should be visible in the request. Have you looked at ALL the cookies?
Bill
Ram Pra
Ranch Hand

Joined: Feb 06, 2001
Posts: 37
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

Joined: Feb 06, 2001
Posts: 37
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

Joined: Mar 04, 2004
Posts: 15
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.


SCJP, SCWCD, SCEA
Ram Pra
Ranch Hand

Joined: Feb 06, 2001
Posts: 37
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access a cookie created using Javascript on the client side from a servlet ?