• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic