Applets using URL and URL Connection for HTTP Tunneling
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Annapurna_B
Posted On:   Thursday, April 26, 2001 06:20 AM

I have a simpleChatServer and an applet that uses this server. I am using a URL Connection at the client side which communicates with the continously running server (a socket waiting)... I created input and output streams for the URL connection created while the applet is loaded. I get messages from the server but I am not able to send messages to the server. In the client I put the messages in the outputstream but I find that the messages are not reaching the server....Let me know if any has a clue why my applet is not working as expected...

Thanks
Annapurna

Re: Applets using URL and URL Connection for HTTP Tunneling

Posted By:   Javier_Caro  
Posted On:   Thursday, April 26, 2001 09:06 AM

Hi Annapurna. I've resolved this problem.
This is the source:

URL url=null;
try{
url=new URL(getCodeBase(),"servlet/unchat.ServletChat");
System.out.println("Se conecta al servlet "+url.getFile());
}catch(Exception ex){
System.out.println("Excepcion al crear URL");
}
URLConnection connection=null;
try{
connection=url.openConnection();
connection.setDoOutput(true);

}catch(IOException ex){
System.out.println("Excepcion CONECTANDO");
}
try{
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println("string=" + textMensajes.getText());
out.close();
}catch(Exception ex){
ex.printStackTrace();
}

You have to send a name of a parameter and the value of the parameter
About | Sitemap | Contact