wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP and Javascript Cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP and Javascript Cookies" Watch "JSP and Javascript Cookies" New topic
Author

JSP and Javascript Cookies

Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Hi,

My simple question is whether I can read cookies set by javascript in JSP and viceversa?

Thanks.
Vikas
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
Vikas,

The answer to your question is yes.

And now I will anticipate your follow-up question: How?

Hint: use the implicit request object in JSP, figure our how that relates to the HttpServletRequest object and how to access its method for retrieving cookies from the request object. You will likely wind up looping through a Cookie[] array.

In javascript use the cookie property of the document.

Good luck!
[ February 09, 2007: Message edited by: Philip Shanks ]

Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Cookies are cookies. Whether set in Javascript, or by other means, they all use the same underlying mechanisnms.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP and Javascript Cookies