Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Shakil Munavary

Greenhorn
+ Follow
since Mar 25, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shakil Munavary


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);
}
}
19 years ago
Dear friends ,
i need a pgrm in applet to chat from one m/c to another m/c.i can do it with applet to application pgm. when i come in for an applet the conection get refused.i did an exmple prgm as sending
a integer no form an applet window as client to server pgm which is written in apln.the server receives the no from aplet &
sends back to client (after squaring).the squared value is displayed in the applet.here by i have given the pgm i have written for server & client chat..pl let me know the errors.
/* the server pgm*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.net.*;
import java.io.*;
/*<applet code=Server.class width="400" height="500">
</applet>*/
public class Server extends Applet implements ActionListener
{
Button b ;
TextArea tr,ts;
public void init()
{
ts=new TextArea(4,10);
tr=new TextArea(4,10);
add(ts);
add(tr);
b=new Button("Send");
add(b);
b.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource()==b)
{ int port= 8080;
ServerSocket ss;

try{
ss=new ServerSocket(port);
Socket s=ss.accept();
PrintWriter toClient= new PrintWriter(s.getOutputStream());
BufferedReader isfromClient=new BufferedReader(new InputStreamReader(s.getInputStream()));
//String data=(String)(isfromClient.readLine());
toClient.println((String)ts.getText());
toClient.flush();
toClient.close();

String str;
while(isfromClient.readLine()!=null)
{
str=isfromClient.readLine();
tr.setText(str);
}
s.close();
}
catch(Exception e1)
{
System.out.println("EROROR is "+e1);
}
/* Socket s=ss.accept();
PrintWriter toClient= new PrintWriter(s.getDataOutputStream());
BufferedReader isfromClient=new BufferedReader(new InputStreamReader(toClient.getDataInputStream()));
String data=(String)(isfromClient.readLine());
tr.setText(data);*/
}
}
}


/* the client pgm*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.net.*;
import java.io.*;
/*<applet code=Client.class width="400" height="500">
</applet>*/
public class Client extends Applet implements ActionListener
{
Button b ;
TextArea tr,ts;
public void init()
{
ts=new TextArea(4,10);
tr=new TextArea(4,10);
add(ts);
add(tr);
b=new Button("Send");
add(b);
b.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource()==b)
{ int port= 8080;
///ServerSocket ss;

try{
//ss=new ServerSocket(port);
Socket s=new Socket("localhost",port);
PrintWriter toServer= new PrintWriter(s.getOutputStream());
BufferedReader isfromServer=new BufferedReader(new InputStreamReader(s.getInputStream()));
//String data=(String)(isfromServer.readLine());
toServer.println(ts.getText());
String str;
while(isfromServer.readLine()!=null)
{
str=isfromServer.readLine();
tr.setText(str);
}
s.close();
}
catch(Exception e1)
{
System.out.println(" The err is "+e1);
}
/* Socket s=ss.accept();
PrintWriter toClient= new PrintWriter(s.getDataOutputStream());
BufferedReader isfromClient=new BufferedReader(new InputStreamReader(toClient.getDataInputStream()));
String data=(String)(isfromClient.readLine());
tr.setText(data);*/
}
}
}

19 years ago