Does anybody know the example using servlet in desktop-application? Or
some site about this?
Usually not in a desktop application but we have deployed many servlet
based systems using only Java SE and an embedded servlet container (we
use Jetty).
We do not like the model of running multiple applications inside a
single generic container. Instead we let each server application run as
a separate process and have it embed a lightweight servlet container
like Jetty. We have all the applications listen on different ports and
run a reverse proxy in front of them to publish the applications via
port 80 but with different URLs (usually based on host-names, sometimes
URI patterns). Since the reverse proxy can do load-balancing as well we
can run multiple instances of the same application when needed.
Although combining a servlet container with a desktop application is not
a problem by itself we have found that desktop applications are usually
run from client machines which can be hard to reach from the outside
(usually router/proxy issues). That makes it somewhat less useful to
contain servlets in a desktop application. But your situation might
differ (as ours has once or twice) and then it is a perfectly fine
combination.
The Jetty website contains source samples of how to embed servlets in
your application.
Best regards,
Silvio Bierman