Applet to servlet communication
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kalyan_Yerramilli
Posted On:   Monday, April 30, 2001 07:20 AM

I've to send some information from applet to servlet. It's working fine when I use Internet Explorer, but problem comes when I use netscape navigater. It's even not connecting to the cencern servlet. Here I've attached source files for both applet and servlet. Please go through them and suggest me in sorting out. Kalyan. Applet code: ------------ import java.applet.*; import java.awt.*; import java.net.*; import java.io.*; public class AppSer extends Applet{ String user; public void init(){ try{ URLConnection con1=new URL(getCodeBase(),"servlet/SertoApp").openConnection(); System.out.println("Codebase &   More>>

I've to send some information from applet to servlet. It's working fine when I use Internet Explorer, but problem comes when I use netscape navigater. It's even not connecting to the cencern servlet.

Here I've attached source files for both applet and servlet.

Please go through them and suggest me in sorting out.

Kalyan.

Applet code:
------------
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.io.*;

public class AppSer extends Applet{
String user;
public void init(){
try{

URLConnection con1=new URL(getCodeBase(),"servlet/SertoApp").openConnection();
System.out.println("Codebase "+getCodeBase());
con1.setUseCaches(false);
con1.setDoInput(true);
con1.setDoOutput(true);
OutputStream os=con1.getOutputStream();
ObjectOutputStream oos=new ObjectOutputStream(os);
oos.writeObject("MyOrganization");
System.out.println("Sent message to the servlet");
os.close();
}
catch(Exception e){System.out.println(e);}

}
public void paint(Graphics g){

if(user==null)user="Kalyan";

g.setColor(Color.blue);
g.setFont(new Font("",Font.BOLD,12));
g.drawString(user,10,10);
}
}

Servlet Code:
--------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class SertoApp extends HttpServlet{

public void service(HttpServletRequest req,HttpServletResponse res){
try{
InputStream is=req.getInputStream();
ObjectInputStream ois=new ObjectInputStream(is);
System.out.println("Organization:: "+(String)ois.readObject());

is.close();

}


catch(Exception e){System.out.println(e);}
}
}

   <<Less
About | Sitemap | Contact