Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why setMaxAge() and getMaxAge() methods are used in Cookies?

Answers were Sorted based on User's Feedback



Why setMaxAge() and getMaxAge() methods are used in Cookies?..

Answer / abhijitbaji

setMaxAge(), this function sets the maximum age of the
cookie.
The value of the maximum age is the lifetime of the cookie
in seconds.
It is a decimal non-negative integer.
When the age is greater than seconds of maximum age, the
client SHOULD discard the cookie.
A value of zero means the cookie SHOULD be discarded
immediately.


getMaxAge(), this function can be used to retrieve the
maximum age of the cookie.

Is This Answer Correct ?    10 Yes 1 No

Why setMaxAge() and getMaxAge() methods are used in Cookies?..

Answer / tulasi vani

Cookies are created as

Cookie c=new Cookie(name,value);
c.setMaxAge(milliseconds);

int getMaxAge() returns the maximum age of the cookie.

If the value is set to zero it will be deleted
immediately.If the age is a -ve number it states that the
age of the cookie is confined to that particular request
only.

Is This Answer Correct ?    2 Yes 6 No

Post New Answer

More Servlets Interview Questions

can we create more than ServletContext and ServletConfig in your application

6 Answers   Patni,


what are the different services provided by the web server?

2 Answers  


What do you mean by session tracking and also explain its techniques?

0 Answers  


What is meant by cookies?

0 Answers  


Explain the difference between generic servlet and http servlet?

0 Answers  


What is the difference between genericservlet and httpservlet

0 Answers  


Can we use the constructor, instead of init(), to initialize servlet?

0 Answers  


What are the differences between the servletconfig interface and the servletcontext interface?

0 Answers  


What is HTTP Tunneling?

1 Answers   Wipro,


When we don't write any constructor for the servlet, how does container create an instance of servlet?

2 Answers   Godrej, TATA,


Can a jsp be called using a servlet?

0 Answers  


What is a servlet-to-servlet communcation?

0 Answers  


Categories