|
 |
pro_java_server thread: Applet-Servlet Communication
Message #1 by "Naveen Kumar" <bommi_k@h...> on Thu, 17 Aug 2000 07:28:55 GMT
|
|
Hai All,
I am want to communicate from an Applet to a Servlet.I wrote the code
but it's not working fine.I am sending u the code.Can anyone help me
out.Also i am calling a Servlet number of times by passing different
paramters and retrieving the results( by using Object Streams) from an
applet in a thread but i am getting Read Timed Out exception ,eventhough i
specifically set a sleep for a long time.Can anyone tell me the reason.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ServTest extends HttpServlet{
public void service(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException
{
ServletInputStream sis = req.getInputStream();
DataInputStream bf = new DataInputStream(sis);
System.out.print(bf.readLine());
}
}
import java.applet.*;
import java.net.*;
import java.io.*;
public class AppTest extends Applet{
public void init(){
try{
URL u=new URL("http://localhost:8080/servlet/ServTest";);
URLConnection uc=u.openConnection();
uc.setDefaultUseCaches(false);
uc.setDoOutput(true);
uc.connect();
DataOutputStream ps =new DataOutputStream(uc.getOutputStream());
ps.writeBytes("Hai How are you");
}catch(Exception ert){}
}
}
|
|
 |