• Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet communicating with Managed Bean

 
Archibald Kemp
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JSF to develop a web app, with backing beans with "session" scope.

Part of the app involves communicating with the local PC's serial port and a certain file on the local C:\ I'm using a signed applet to handle this part.

Now the applet needs to talk to the backing bean. (Not just stuff that can be passed as applet parameters, but throughout the life of the applet). I need something like a Home & Remote Interface to the backing bean, so that the applet can call its methods.

Has anybody done something like this?

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The backing bean is under the control of the servlet engine; I don't think it'd be a good idea to have it communicate with the outside world.
RMI uses a mechanism similar to Home/Remote interfaces, but you'd have to adapt your backend design for it. But that's probably the case for any solution.
 
Tim Holloway
Bartender
Posts: 18418
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two possibilities.

1. Use HTTP tunneling. This will require some sort of servlet to handle the actual communications with the bean, as neither http nor the servlet spec provide for direct access to Java session objects. A heavier variant of HTTP tunnelling is to implement a Web Service.

2. Use an RMI interface. Either raw RMI or an EJB. It's NOT a good idea to make an RMI-managed object be an http session object due to threading issues. EJBs manage their own thread-safeness but only within the protocols.

Http tunnelling is generally the way to go for something like this. Rather than expect a client to know the internals of the server setup, use a service point. The extra overhead's rarely significant and the app is generally going to be a whole lot easier to develop, debug, and maintain.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!