Applet/Servlet communication: what are your thoughts on this?

I've been reading up on Applet/Servlet communication ( http://www.unix.org.ua/orelly/java-ent/servlet/ch10_01.htm ) in the hopes of someday updating my very strange chatroom (an amalgam of JSP, PHP, servlets, XML and stuff I can't even identify), and I noticed that there are several methods for passing data between client applet and remote servlet including:

1) HTTP

2) non-HTTP Socket

3) RMI

I also noticed the advantages and disadvantages of using each one and honestly, I can't decide what is best and what should I avoid.

The basic premise is a simple messaging chatroom applet with HTML-enabled messages (with limited HTML capability for obvious security reasons) passed onto a remote host servlet back and forth until you're done.

What experiences might you have had that would ensure that the best-practice method would be either HTTP, non-HTTP Socket or RMI?

Just wondering at this point, nothing implemented as of yet

Thanks

Phil

[1005 byte] By [ppowell777a] at [2007-11-27 2:22:32]
# 1

> 1) HTTP

Easiest way to go, since most Servlet's are implemented as HttpServlet. Not the absolute most efficient protocol (in terms of latency) but very quick to develop and straightforward.

> 2) non-HTTP Socket

The most efficient way to go (other than NIO). However, you would be writing a custom protocol. Optimization would be up to you, but the system could be far more efficient than RMI or HTTP. Then again, maintaining and documenting the protocol might end up costing more in the long run. You also would not be taking advantage of open standards. As always, there are trade-offs.

> 3) RMI

The least desirable option, IMO. Java serialization is used to send POJO's over the wire. For simple messages (such as a series of strings), this is way, way overkill. For a complex message object, the performance will probably be better than XML-RPC or a SOAP call. But those have the advantages of open standards. This would be my third-place pick.

To your options above, you may consider JAXB (to marshall and unmarshall XML to POJO's) or a proper web service ala SOAP (could be REST as well).

- Saish

Saisha at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks! One more thing: should I use HTTP, thus, should I employ via HTTP text or HTTP objects when passing messages back and forth?
ppowell777a at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 3
What is "HTTP text" and "HTTP Objects"?
tsitha at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 4
> What is "HTTP text" and "HTTP Objects"?It is referring to the different means of passing arguments (see http://www.unix.org.ua/orelly/java-ent/servlet/ch10_01.htm for more information)
ppowell777a at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 5
I don't think "page deleted" is enough more information that we can tell what you meant.
DrClapa at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 6
BTW you can't do RMI to a servlet. You can run an RMI server inside a servlet but then it's not really a servlet any more, it's just a dummy framework for hosting an RMI server.
ejpa at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 7

> BTW you can't do RMI to a servlet. You can run an RMI

> server inside a servlet but then it's not really a

> servlet any more, it's just a dummy framework for

> hosting an RMI server.

I'm afraid I don't understand why it is no longer a servlet in this case, please explain, thanx

ppowell777a at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 8
A servlet is a mini-server that receives HTTP requests and is hosted by a servlet container.An RMI server is a mini-server that receives RMI requests and doesn't have to be hosted by anything. It can be hosted by a servlet but that doesn't make it a servlet.
ejpa at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...
# 9

> A servlet is a mini-server that receives HTTP requests and is hosted by a servlet container.

That is a HTTP servlet. However, other types of servlet are certainly possible. That is why HttpServlet implements Servlet.

Granted, it might be lipstick on a pig, but it would still "count" in my book as a Servlet if the OP implements the interface. :^)

- Saish

Saisha at 2007-7-12 2:26:58 > top of Java-index,Java Essentials,Java Programming...