IT Community - Software Programming, Web Development and Technical Support

Cookies

This is a discussion on Cookies within the Java Server Pages (JSP) forums, part of the Web Development category; Is it ok if you regularly delete cookies in JSP? If it is alright, how do you delete my cookies?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Java Server Pages (JSP)

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-09-2007, 10:02 AM
nhoj nhoj is offline
D-Web Programmer
 
Join Date: Apr 2007
Posts: 96
nhoj is on a distinguished road
Default Cookies

Is it ok if you regularly delete cookies in JSP? If it is alright, how do you delete my cookies?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 07:53 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Thumbs up Re: Cookies

Hi.....

cookie can be deleted using the following scriptlet:

<%
Cookie killMyCookie = new Cookie("mycookie", null);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);
%>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-14-2007, 07:38 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Default Re: Cookies

There are two kinds of cookies in jsp: persistent cookies and temporary cookies.

A persistent cookie is one stored as a file on your computer, and it remains there when you close Internet Explorer. The cookie can be read by the Web site that created it when you visit that site again. You can use cookie.setMaxAge(s) to set the cookie to be persistent for 's' seconds.

A temporary or session cookie is stored only for your current browsing session, and is deleted from your computer when you close Internet Explorer. You can use cookie.setMaxAge(-1) to set the cookie to be temporary.

setMaxAge(): Defines how long the cookie should be stored on the browser's machine. MaxAge value is in unit of second. A negative value tells the browser to not save it to the harddisk. A zero value tells the browser to delete it.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-17-2007, 06:28 AM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Default Re: Cookies

Hi,
javax.servlet.http
Class Cookie

java.lang.Object
|
+--javax.servlet.http.Cookie

All Implemented Interfaces:
java.lang.Cloneable

public class Cookie
extends java.lang.Object
implements java.lang.Cloneable

Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.

A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. Some Web browsers have bugs in how they handle the optional attributes, so use them sparingly to improve the interoperability of your servlets.

The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.C ookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.

The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the HttpServletRequest.getCookies() method. Several cookies might have the same name but different path attributes.

Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created with this class. This class does not support the cache control defined with HTTP 1.1.

This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability.
__________________
Krishnakumar.S
Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-29-2008, 12:32 AM
danica danica is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 18
danica is on a distinguished road
Default Re: Cookies

HTTP cookies, or more commonly referred to as Web cookies, tracking cookies or just cookies, are parcels of text sent by a server to a Web client (usually a browser) and then sent back unchanged by the client each time it accesses that server. HTTP cookies are used for authenticating, session tracking (state maintenance), and maintaining specific information about users

_______________________

Keyword Research Georgia Health Insurance
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Cookies Overview KiruthikaSambandam ASP and ASP.NET Programming 8 05-30-2008 02:10 AM
Cookies before start using in php vigneshgets PHP Programming 1 01-18-2008 04:18 AM
Creating Cookies pranky HTML, CSS and Javascript Coding Techniques 2 11-21-2007 05:02 AM
Cookies ragavraj PHP Programming 4 11-01-2007 12:48 PM
Cookies vs. Sessions vijayanand PHP Programming 3 08-13-2007 08:36 AM


All times are GMT -7. The time now is 10:39 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0