Silvia Gaspar wrote:
>
> Thank you very much. Can you, please tell me how can the applet do
> this. Do you have any example?
This code is not complete. It only has enough to show getting a cookie
and setting a cookie. Actually getting a page or sending GET or POST
data is not shown. Replace www.server.com with the name of a server that
sends a cookie when you access the site:
import java.net.*;
import java.io.*;
public class CookieDemo {
private String cookie;
public static void main(String[] args) {
CookieDemo c = new CookieDemo();
c.getCookie();
}
public void getCookie () {
try {
URL url = new URL("http://www.server.com/");
URLConnection connection = url.openConnection();
InputStream in = connection.getInputStream();
cookie = connection.getHeaderField("Set-Cookie");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(cookie);
}
public void sendCookie() {
try {
URL url = new URL("http://www.server.com");
URLConnection connection = url.openConnection();
connection.setUseCaches(true);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("COOKIE", cookie);
} catch (Exception e) {
e.printStackTrace();
}
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html