Call for New Batch / Any Query / Demo Classes : ☎ 08871209400 , 7987028543 , Zone-2,M.P.Nagar,Bhopal

Class Cookie


Package javax.servlet.http

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.Cookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time.

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.

Class Cookie Constructor

Constructor Summary
Cookie(java.lang.String name, java.lang.String value)
Constructs a cookie with a specified name and value.

Class Cookie Constructor Detail

Cookie

public Cookie(java.lang.String name,
java.lang.String value)

Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

Cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

Parameters

name - a String specifying the name of the cookie
value - a String specifying the value of the cookie

Throws

java.lang.IllegalArgumentException - if the cookie name contains illegal characters or it is one of the tokens reserved for use by the cookie protocol

Class Cookie Method

Method Summary
java.lang.Objectclone()
Overrides the standard java.lang.Object.clone method to return a copy of this cookie.
java.lang.StringgetComment()
Returns the comment describing the purpose of this cookie, or null if the cookie has no comment.
java.lang.StringgetDomain()
Returns the domain name set for this cookie.
intgetMaxAge()
Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.
java.lang.StringgetName()
Returns the name of the cookie.
java.lang.StringgetPath()
Returns the path on the server to which the browser returns this cookie.
booleangetSecure()
Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
java.lang.StringgetValue()
Returns the value of the cookie.
intgetVersion()
Returns the version of the protocol this cookie complies with.
voidsetComment(java.lang.String purpose)
Specifies a comment that describes a cookie's purpose.

References By : apache « Privious Post » « Next Post » share on :        :  

Love to hear your Views / Guidance / Recommendations on this Post…

Explore the Technology World

How to Build an App for the Google AssistantApps for the Google Assistant are the gateway for your users to engage with your services through Google Home, Android phones, iPhones.Watch here to build an as ...Read MoreIntroduction to AMP - Accelerated Mobile PagesAMP, short for Accelerated Mobile Pages, is new new open source initiative to make the mobile web awesome again.Watch Here the Introduction to AMP ...Read MoreHadoop - Just the Basics for Big Data Rookies (Best online tutorial)This Tutorials assumes absolutely no knowledge of Apache Hadoop and will provide a complete introduction to all the major aspects of the Hadoop ecosystem of pro ...Read MoreGoogle Python online tutorial-Interested in learning python? Then you must watch this videoPython is a dynamic, interpreted (bytecode-compiled) language. There are no type declarations of variables, parameters, functions, or methods in source code.wat ...Read Morelatest product and platform innovations at Google by Sundar PichaiLearn about the latest product and platform innovations at Google in a Keynote led by Sundar Pichai.Video is also subtitled in Chinese, Indonesian, Italian, Jap ...Read MoreFuture of the Java Platform and the JDKJava has been one of the most popular programming platforms in the world for twenty-three years as One Language, One Platform, a Lifetime of Opportunity. How d ...Read More

Call / Visit for New Batch

Services

Why Join Us

  • ➯ Free Demo Classes
  • ➯ No Registration Fee
  • ➯ Interview Questions
  • ➯ Study Materials
  • ➯ Softwares
  • ➯ Aptitude & Reasoning
  • ➯ Placement Assitance

Address

  • MyJava Training Institute ,
  • Plot No.243 , shop No 14 ,
  • Secnd Floor , Zone-II ,
  • M.P.Nagar , Bhopal,
  • Madhya Pradesh ( 462011 )
  • ☎  08871209400 , 7987028543
  • 🌐 www.myjava.in
FacebookGoogle +TwitterYouTube

MyJava - java Training Institute