N�o sei como fazer isso em java. Mas em termos de HTTP, voc� deve passar o HTTP header Connection com o valor Keep-Alive.
 
Ent�o o trafego de saida (aplica��o java -> servidor) da sua conex�o HTTP ficaria assim (exemplo do seria trafegado usando o IE):
 
 
GET / HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: pt-br
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost
Connection: Keep-Alive
POST /login HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: pt-br
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost
Connection: Keep-Alive
DADOS DO POST AQUI
POST /other HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: pt-br
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: localhost
Connection: Keep-Alive
DADOS DO POST AQUI.
 
 
 
 
 
----- Original Message -----
Sent: Friday, November 01, 2002 2:54 PM
Subject: [cejug-discussao] URLConnection

Como eu posso usar uma mesma conexao para acessar dois servi�os diferentes
no servidor:

tipo:

step 1: conect to server (http://localhost)
step 2: enviar dados para um servico (http://localhost/login)
e receber o respectivo retorno
step 3: enviar dados para outro servico no mesmo endereco
(http://localhost/other)
e receber o respectivo retorno



segue abaixo um fragmento do c�digo...

// AQUI: o servidor � o "localhost".. depois eu queroi definir os caminhos
dos servicos...
            URL serverURL = new URL(server);
            URLConnection connection = Handshake.getConnection(serverURL,
truststore, truststorePassword);
            System.out.println("conectado");

            // Prepare the connection for recieving the form
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setUseCaches(false);
            connection.setAllowUserInteraction(true);

            // Definindo o tipo de mensagem como multipart form-data
            connection.setRequestProperty( "Content-Type",
"multipart/form-data; boundary=" + BOUNDARY);

            // Abrindo um canal de sa�da na conex�o com o servidor
            DataOutputStream postStream = new
DataOutputStream(connection.getOutputStream());




Responder a