Board index » jbuilder » Applet and RMI

Applet and RMI


2003-12-31 01:22:28 PM
jbuilder2
I want to connect to JDBC using Applet . If i use JSP then the page is
refreshed each time i need
server side interaction. If i use RMI such page refresh is avoided. But for
RMI i need the stub file
and the Interface file to be installed at client end. The server side
interaction is required quiet a
number of times in the same page. How do i solve this problem?
I have deployed the file in tomcat server:-
Directory Server has files - appInterface.class,
appImplement.class,appImplement_skeleton ,
appImplement_stub,appServer.class , Client.jar (appClient.class,
appImplement_stub,
appInterface.class), Client.html ;
The Client.html calls for the applet appClient.class in the Client.jar
archieve.
When i run the applet thru http://localhost:8080 :- it gives no error but
the applet is not executing
the method (which is called thru RMI). Where shall i lookup the error if
any? The applet runs fine
when not thru http.
=======================================================
computer1: the browser, with the applet
computer2: the webserver (port 80), the rmi server (port 2001??), AND
a naming service, such as the "rmiregistry" (default port 1099) (some
other name server will work...)
?? how to change port for the rm server..rt now it is running at default
port ..i dont know which
 
 

Re:Applet and RMI

I want to connect to JDBC using Applet . If i use JSP then the page is
refreshed each time i need server side interaction. If i use RMI such page
refresh is avoided. But for RMI i need the stub file and the Interface file
to be installed at client end. The server side interaction is required quiet
a number of times in the same page. How do i solve this problem?
When i run the applet thru http://localhost:8080 :- it gives no error but
the applet is not executing the method (which is called thru RMI). Where
shall i lookup the error if any? The applet runs fine when not thru http.
I have deployed the file in tomcat server:-
Directory Server has files - appInterface.class,
appImplement.class,appImplement_skeleton ,
appImplement_stub,appServer.class , Client.jar (appClient.class,
appImplement_stub,
appInterface.class), Client.html ;
The Client.html calls for the applet appClient.class in the Client.jar
archieve.
computer1: the browser, with the applet
computer2: the webserver (port 80), the rmi server (port 2001??), AND
a naming service, such as the "rmiregistry" (default port 1099) (some
other name server will work...)
?? how to change port for the rm server..rt now it is running at default
port ..i dont know which
 

Re:Applet and RMI

Rina Agarwal wrote:
Quote
I want to connect to JDBC using Applet . If i use JSP then the page is
refreshed each time i need server side interaction. If i use RMI such page
refresh is avoided. But for RMI i need the stub file and the Interface
file to be installed at client end. The server side interaction is
required quiet a number of times in the same page. How do i solve this
problem?

When i run the applet thru http://localhost:8080 :- it gives no error but
the applet is not executing the method (which is called thru RMI). Where
shall i lookup the error if any? The applet runs fine when not thru http.


Is the Applet Code signed? I will assume the answer is yes.
I do mnot understand the last part,"The applet runs fine when not through
http. If you are doing an RMI call from the applet directly, what is the
http for?
Quote
I have deployed the file in tomcat server:-
Directory Server has files - appInterface.class,
appImplement.class,appImplement_skeleton ,
appImplement_stub,appServer.class , Client.jar (appClient.class,
appImplement_stub,
appInterface.class), Client.html ;

The Client.html calls for the applet appClient.class in the Client.jar
archieve.

computer1: the browser, with the applet
computer2: the webserver (port 80), the rmi server (port 2001??), AND
a naming service, such as the "rmiregistry" (default port 1099) (some
other name server will work...)

?? how to change port for the rm server..rt now it is running at default
port ..i dont know which
You can change the port by simply assigning it to the URL, example:
Sring name="//somehost:1234";
Here is a full simple RMI Server example (class only, not interface)
package engine;
import java.rmi.*;
import java.rmi.server.*;
import taskclass.*;
public class TaskEngine extends UnicastRemoteObject
implements Task
{
public TaskEngine() throws RemoteException {
super();
}
public Object executeTask(Task t) {
return t.execute();
}
public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
String name = "//host/Task:1234"; //using an optional port
try {
Task aTask = new TaskEngine();
Naming.rebind(name, aTask);
System.out.println("TaskEngine up and running");
} catch (Exception e) {
System.err.println("TaskEngine exception: " + e.getMessage());
e.printStackTrace();
}
}
}
Your client would connect by the following example (applet or application)
package client;
import java.rmi.*;
import java.math.*;
import compute.*;
public class TaskPi {
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
String name = "//" + args[0] + "/Task";
Compute myTask = (Task) Naming.lookup(name);
Pi task = new Pi(Integer.parseInt(args[1]));
BigDecimal pi = (BigDecimal) (task.executeTask(task));
System.out.println(pi);
} catch (Exception e) {
System.err.println("TaskPi exception: " + e.getMessage());
e.printStackTrace();
}
}
}
Hope this helps!!
 

{smallsort}

Re:Applet and RMI

Please do not multi-post. It is against the newsgroup rules.
This question was answered in another newsgroup.
--
Regards,
Lori Olson (TeamB)
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html