I have question about servlet, currently I have a Java socket program that needs to be continuously running (monitoring a device), and I want to write a web application to talk to the socket program.
is it possible to launch a servlet thread from my java program when a http request is received? does anyone know how to do that with netbean?
my first plan was to use servlet to make a socket connection to talk to my java socket program upon HTTP request, but then the servlet would have to create and terminate a socket for every page request, that would create delays, i think there is a better way of doing this but i dont know how, can someone give me some ideas? either using servlet or other method.
If you are planning to display some data related to that monitoring in that web application,Then that standalone socket program needs to write the information in a data source ( file or database).The web application servlet will communicate with the data source to display the data.I hope the web application will be the readonly consumer for the data source.
One approach would be to make all information available via JMX. Then a JMX client can connect to it from remote, retrieve the information, and display it any which way it wants. It wouldn't even have to be read-only - the JMX client can be used to influence the remote app, and t could be embedded in a standalone Java app, a Java web app, or you can use a read-made JMX client such as JConsole or VisualVM (both of which come with the JDK).
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop