HttpCookie GetDomain() Example
Returns the domain name set for this cookie.
HttpCookieclass GetDomain() method example. This example shows you how to use GetDomain() method.This method Returns the domain name set for this cookie.
Here is the code:-
/*
* @Program that Returns the domain name set for this cookie.
* GetDomain.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.net.*;
public class GetDomain {
public static void main(String[] args) throws Exception {
String name = "Name";
String value = "ABC";
HttpCookie hc = new HttpCookie(name, value);
hc.setDomain(".com");
//Returns the domain name set for this cookie.
System.out.println("The domain name set is: "+hc.getDomain());
}
} |
Output of the program:-
| The domain name set is: .com |
|