HttpCookie SetValue() Example
Assigns a new value to a cookie after the cookie is created.
HttpCookieclass SetValue() method example. This example shows you how to use SetValue() method.This method Assigns a new value to a cookie after the cookie is created.
Here is the code:-
/*
* @Program that Assigns a new value to a cookie after the cookie is created.
* SetValue.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.net.*;
public class SetValue {
public static void main(String[] args) throws Exception {
String name = "Roseindia";
String value = "ABC";
HttpCookie hc = new HttpCookie(name, value);
//Returns the value of the cookie.
System.out.println("The value of the cookie is: "+hc.getValue());
//Assigns a new value to a cookie after the cookie is created.
hc.setValue(".Net Rohini");
System.out.println("The value of the cookie is: "+hc.getValue());
}
} |
Output of the program:-
The value of the cookie is: ABC
The value of the cookie is: .Net Rohini |
|