On Thursday, February 25, 1999 4:05 PM, Craig R. McClanahan
[SMTP:[EMAIL PROTECTED]] wrote:
> "Brian P. Rickabaugh" wrote:
>
> > Hello all:I've seen this mentioned several times but I don't know if
> > I've ever seen a definitive answer.I have 2 servers and 1 servlet on
> > each each server. What is the _best_ way to have them communicate?
> > Is my only hope HTTP?Thanks,Brian
>
> What (besides HTTP) would you suggest? After all, that's what (most)
> servlets do -- answer HTTP requests!
>
> As it happens, making HTTP requests from one servlet to another is
> really easy, using the java.net.URLConnection or
> java.net.HttpURLConnection classes that are built in. The Javasoft
> online tutorial has some good examples of how to do this.
>
> Using HTTP means you are "limited" to the normal request/response
> paradigm, of course. If you need more interactivity than that with the
> second server, you might investigate making your application on that
> machine an RMI or CORBA-based server object, or an EJB, instead of a
> servlet. Then, you can essentially call the remote methods directly.
And don't forget that you've also got all the other
communication methods possible with Java or the
underlying system:
+ sockets (one or both servlets can implement a tiny
custom server and listen on a socket while the other
writes to it. You don't need to implement anyone's
protocols but your own.)
+ jdbc (if you just want to transfer data between
machines, giving them both access to a shared database
is often a neat way to do it.)
+ mail (it may seem wierd, but if you don't need
synchronous transfers, you can use JavaMail at both
ends and send a simple email.)
+ ftp etc. (ftp clients are easy to write or get hold
of. just transfer any data to the other system using
ftp and simply read the file at the other end.)
+ nfs or file sharing (if you can share any directories
or files between the machines at the OS level, then
the sender just needs to write a file, and the
receiver read from it.)
And so on. They key thing to bear in mind here is
that just because you are using the Servlet API to
interface your code with a HTTP server, doesn't mean
that you've lost the use of the rest of Java, or that
you can't use other OS features if you need them
--
Frank Carver
[ Personal: [EMAIL PROTECTED] http://www.io.com/~efficacy ]
[ At Work: [EMAIL PROTECTED] tel +44 (0)1473 227371 ]
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html