Listing 3: SettingCookies.java
import java.net.*;
import java.io.*;
import java.util.*;
class read{
public read(){}
BufferedReader buffer=null;
String linie=null;
HttpURLConnection URLcon=null;
URL url=null;
InputStream IS=null;
int cookie_nr=0;
public void getURLContent()
{
try {
//optional - for proxy connection used
InetAddress addr=InetAddress.getByName("www-proxy.omv.com");
InetSocketAddress ISA=new InetSocketAddress(addr,8080);
java.net.Proxy proxy=new java.net.Proxy(java.net.Proxy.Type.HTTP,ISA);
url=new URL("http://java.sun.com");
URLcon = (HttpURLConnection)url.openConnection(proxy);
String cookie="name_1=value_1;name_2=value_2;... name_n=value_n";
URLcon.setRequestProperty("Cookie",cookie);
URLcon.connect();
System.out.println(URLcon.getResponseMessage());
}catch(MalformedURLException e)
{System.out.println("Eroare:"+e.getMessage());
}catch(IOException e)
{System.out.println("Eroare:"+e.getMessage());}
}
}
public class SettingCookies{
public static void main(String[] args)
{
read t=new read();
t.getURLContent();
}
}
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|