• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet with RMI

 
Shakil Munavary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am sending a program which is used to connect to remote JDBC with applet.I am getting error message saying Access denied.please give me a solution for this problem.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
import java.rmi.*;
import java.net.*;
import java.rmi.server.*;
/*
<applet code=en width=300 height=300>
</applet>
*/
class En6 extends Frame implements ActionListener,Serializable
{
String msg,msg1,msg2,msg3,msg4;
Button b,b1;
TextArea ta,ta1;
Label l1;
// Frame f=new Frame();
public En6()
{
super();
setLayout(new FlowLayout(FlowLayout.LEFT));

b = new Button("Submit");
ta = new TextArea(10,10);
b1 = new Button("post");
ta1 = new TextArea(10,10);
l1=new Label(" ");
add(l1);
add(b);
add(ta);
b.addActionListener(this);
add(b1);
add(ta1);
b1.addActionListener(this);



}
public void actionPerformed(ActionEvent ae)
{
String str = ae.getActionCommand();


try {
//UnicastRemoteObject.exportObject(this);
String addServerURL = "rmi://100.100.10.125/AddServer5";
AddServerIntf5 addServerIntf = (AddServerIntf5)Naming.lookup(addServerURL);
if(str.equals("Submit"))
{msg1=ta.getText();
msg2=addServerIntf.select(msg1);}
if(str.equals("post"))
{msg4=ta1.getText();
msg2=addServerIntf.select1(msg4);}

}
catch (Exception e)
{
System.out.println("Exception:shyam "+e);
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg2,300,200);

}

public static void main(String arg[])
{
En5 e1=new En5();
e1.setSize(300,300);
e1.setVisible(true);
}
}
 
Ashwin Desai
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
The applet is not allowed to open socket connections (which RMI does implicitly) to any host other than the host (exact IP address) from where it was loaded. You might consider signing your applet (which is costly) which could allow this kind of behaviour.
If possible, deploy the rmi server on the webserver machine from where the applet is loaded.
Also, IE does not support RMI. You will need to download a patch from their website.
Hope this helps.
Ashwin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic