Re: How do I design this application ? (remote server procedures,
etc.)
Me wrote:
On Fri, 24 Apr 2009 17:10:44 +0000, Me wrote:
The web page can connect to the server with GET, POST or (optimally)
AJAX http://www.w3schools.com/Ajax/Default.Asp
What are the data formats of these types of connections ? Ideally the
applet would communicate directly with the weather instrument, ie send
RS232 messages back and forth to it.
GET is just a Socket with the word "GET" in it. There's a bit more than
that but that's the basics.
Try this:
1. Start telnet in a command line window.
2. Connect to host cnn.com on port 80.
3. Type GET and press enter
See what happens.
So the rxtx stuff would sit in the servlet and do the I/O with the
weather station and send the data on to the applet that runs in the
client browser.
More or less.
Are servlets written in Java or Javascript ?
Java. Your applet is called by the web server.
public class MyServlet extends HttpStuff {
... // code your IO here
}
Is the basic pattern.
The weather station server needs to log the data from the weather station
instrument. Can a servlet run when a web page isn't accessing it, ie run
as its own process ? Or is there a better way to write the server part ?
Yes and no. It is possible to launch threads from the web server and
run those in the background. I don't know if it's a great idea. There
may be funky complications.
What if I wrote the server process as a stand alone process and talked to
it from the applet via a socket ? Is an applet allowed to connect to a
separate socket on the server ?
Yes. So is an application downloaded from a server. The really big
question is: do you save time and effort installing and learning Apache
+ JEE or do you just implement a simple service and duplicate the small
amount of functionality you need? It sounds to me like doing the whole
thing in Java and skipping both Apache and JEE is feasible for you, but
this could also be a huge judgment call.