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  
Old 04-09-2007, 09:02 AM
nhoj nhoj is offline
D-Web Programmer
 
Join Date: Apr 2007
Posts: 95
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
  #2  
Old 07-20-2007, 06:53 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
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  
Old 08-14-2007, 06:38 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 190
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  
Old 08-17-2007, 05:28 AM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 200
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  
Old 09-28-2008, 11:32 PM
danica danica is offline
D-Web Trainee
 
Join Date: Sep 2008
Posts: 12
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

Last edited by arjkhanna : 09-25-2009 at 04:22 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 07-23-2009, 07:30 PM
dogfence dogfence is offline
D-Web Trainee
 
Join Date: Jun 2009
Posts: 17
dogfence is on a distinguished road
Default Dog fence reviews

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 09-18-2009, 12:44 AM
johnswhite johnswhite is offline
D-Web Trainee
 
Join Date: Sep 2009
Posts: 2
johnswhite is on a distinguished road
Default Re: Cookies

Ya its possible to delete cookies at the regular basis... as per that when you delete it that time also that data lost... Thanks for sharing the post...
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 Off
Pingbacks are Off
Refbacks are Off

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


All times are GMT -7. The time now is 06:05 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0