-1

I have to do an implementation for a class in the Java language by using Tomcat 7 and Axis2 under Ubuntu 11.10 32bit.

The requirement is to make a dynamic web-server project for simple registration, register and unregister course. Also, each faculty handle their courses and the student will be able to connect to all the courses in all the faculties.

serverImp.java

class serverImp{
    HashMap<String,Intager> courses;
    public String register(String courseID){
        int tmp=courses.get(coursesID);
        courses.add(coursesID,tmp-1);
    }

    public String register(String courseID){
        int tmp=courses.get(coursesID);
        courses.add(coursesID,tmp+1);
    }

}

This is only an example there is more functions of the web-server. Now I have to run the same implementation more than one time with the different name.

for example:

  • localhost:8080/art/
  • localhost:8080/eng

I've done all this and I can make a client for one server, but the problem now is that how I can make the web server client work with all this servers using only one stub??

Jonathan Spooner
  • 7,682
  • 2
  • 34
  • 41
user8580
  • 13
  • 2

1 Answers1

0

problem is solved. just modify the stub by changing the URL from server to another server.
what i did is add into the stub

private static String serverID;
public static void setServer(String name){
    serverID=name;
}

and change the url in the constructor method from "loclhost:8080/art/......" to "loclhost:8080/"+serverID+"/......".


in the client.java I did

public class client {
private static ServerStub stub;
public static void main(String[] args) {
    try {
        stub.setServer("Art");
        stub= new ServerStub();
        Register reg= new Hello();
        reg.setName("Art101");
        RegisterResponse replay= stub.register(reg);
        System.out.println(replay.get_return());

        stub.setServer("Eng");
        stub= new ServerStub();
        Register reg= new Hello();
        reg.setName("com201");
        RegisterResponse replay= stub.register(reg);
        System.out.println(replay.get_return());            
    } catch (AxisFault e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}}
user8580
  • 13
  • 2