This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSP and the fly likes Setting Cookies in Java or JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Setting Cookies in Java or JavaScript" Watch "Setting Cookies in Java or JavaScript" New topic

Setting Cookies in Java or JavaScript

Saulo Menezes

Joined: Jan 15, 2003
Posts: 17
I am currently studying the subject 'Cookies' and up to now I am a bit confused.
My group and I are about to create a site that will use solely jsp pages. In it I am in charge of the cookies.
The teacher intructed us to use JavaScript for that but I found out that it can be done using varied scripts or programming languages. Would anyone be able to tell me which would be the best solution? I intend to keep the date on the client-side.
[ March 26, 2003: Message edited by: Saulo Menezes ]
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You can use Javascript to manipulate cookies on the client (browser) side. Javascript is the only client side scripting language with wide support. Note that Javascript has practically nothing to do with the Java language.
On the server side you have to use the Servlet and JSP APIs to manipulate cookies.
Geeta Ramasami
Ranch Hand

Joined: Mar 05, 2003
Posts: 72
To be more explanatory, if u want to store and user information on the client side u go in for cookies.If u want to store any user information on the server side u go in for session objects.
With respect to cookies u can create it on the client side using javascript as well as on the server side using JSP or servlets.
As ur cookie is however going to be stored in the client machine its better to create in client side as creating it on the server side involves an extra overhead of sending that cookie with the response object
I agree. Here's the link:
subject: Setting Cookies in Java or JavaScript
It's not a secret anymore!