0

hi All,
I m a student....
I am assigned a project in java course to develop a "Ftp Server using RMI"....

Requirememts:-

Requriments are not so high....
It should be a simple one...
Ftp Server could add, remove, view users and statistics through proper GUIS.....
Ftp Client shloud be logged in, authorized before , through proper GUIS.....server will authorize user through database using JDBC....

Client can download and upload a file from server...

Please send me some alogorithm that how should i start...
Any code example help would be appreciated...
thanx in advance....
bye

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by hira ahmad
0

Show us some effort from your side first, how would you go about implementing such a project we would like to know that first. Then you could maybe ask us specific questions than "Please send me some algorithm", and we would be glad to help you.

0

Here is the effort that i have made:plzzzzzzz help me...
the Interface

import java.io.*;
import java.rmi.*;
public interface p extends Remote {
public String sq () throws RemoteException;
public void Login() throws RemoteException;
}
The Implementation


import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
//import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class pImpl extends UnicastRemoteObject implements p , ActionListener{
pImpl() throws RemoteException
{super();}


public String sq ( ) throws RemoteException{
return "Hello from RMI....s server";
}


//*****************************************
public void Login() throws RemoteException{


f=new JFrame("Student Login");


f.setLayout(new FlowLayout());
tf=new JTextField(20);
p=new JPasswordField(20);
l=new JLabel[2];
b=new JButton[2];


for(int i=0;i<l.length;i++){


l=new JLabel();
b=new JButton();}


l[0].setText("Enter ID:");


l[1].setText("Enter Password:");


b[0].setLabel("Login");
b[1].setLabel("Cancel");


f.add(l[0]);
f.add(tf);
f.add(l[1]);
f.add(p);



for(int i=0;i<b.length;i++){
f.add(b);
b.addActionListener(this);}


f.setVisible(true);
f.setSize(650,600);
f.setResizable(false);


}


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


if(str.equals("Login"))
try{
String login=tf.getText();
String pass=p.getText();
String message = "Error : Invalid username/Password";


dbServer db=new dbServer();


if(db.getLogin(login,pass))
{System.out.println("Yes");
f.setVisible(false);}
else
{


JOptionPane.showMessageDialog(f, message, "Dialog",
JOptionPane.ERROR_MESSAGE);
tf.setText("");
p.setText("");
}



} catch (Exception e1){ e1.printStackTrace();}


else if(str.equals("Cancel"))
{f.setVisible(false);
}
}
JTextField tf ;
JPasswordField p ;
JLabel l[] ;
JButton b[] ;
JFrame f ;
//ObjectOutputStream out;
//ObjectInputStream in;



}

The Server

import java.io.*;
import java.rmi.*;
public class pServer {
public static void main (String o[]){
try {
pImpl ob= new pImpl();
Naming.rebind("rmi://localhost:2005/lahore",ob);
System.out.println ("RMI Server  ready...");
} catch ( Exception e ) {
System.out.println ("Server not ready...");
e.printStackTrace();}



}
}

The databse server with dsn name:u and using access database login

import java.sql.*;



public class dbServer {
dbServer()throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("Jdbc:Odbc:u");
st=con.prepareStatement(lgn);


}
public boolean getLogin(String u, String p)throws Exception{
st.setString(1,u);
st.setString(2,p);
rs=st.executeQuery();


if (rs.next())
return true;
else
return false;



}


Connection con;
PreparedStatement st;
ResultSet rs;
String lgn="Select * from login where username = ? and password=?";
}

The Client

import java.rmi.*;
import java.io.*;
public class pClient {
public static void main(String o[]){
try {
p  r= (p)Naming.lookup("rmi://localhost:2005/lahore");


//System.out.println(r.sq());
r.Login();
}
catch (Exception e ) { e.printStackTrace();}
}
}

Edited by pritaeas: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.