-1

Background

I am using a Java application that starts, runs, produces data continuously for a long period (i.e., hours), and shuts down only when explicitly instructed to do so. It has a Java-based GUI that appears on the machine where the application runs. The GUI is very difficult to extend for my purposes, and not useful if I run the application on a headless remote server. I would like to construct a web interface for this application where users can request data from the running application, visualize retrieved data, and send commands to change the operation of the application. AJAX requests from a browser to the application will suffice for my purposes. I have investigated how to do this, and all solutions seem to require heavy-duty, external server setup (e.g., Tomcat) or start-from-scratch (e.g., socket) development. This seems absurd given the conceptual simplicity of the task: all I need to do is respond to an HTTP request. There has to be something simpler and lighter weight than these approaches, especially because I'm prototyping. What's the simplest option?

Question

What is the simplest way to respond to AJAX in an existing Java application without setting up an external server?

0

2 Answers 2

1

You'll want to create an integrated http server (it's the only way to do it) but you can use something like Jetty that should be lightweight and quick to manage.

The answer by Kris in the following question should help you:

Create a simple HTTP server with Java?

Here is the as of current documentation for embedding Jetty

(Credit to Dylan Knowles)

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! I hadn't seen that. After a bit of sleuthing I found the current documentation for embedding Jetty, which seems to be exactly what I need. Can you put that in your answer as well for completeness?
0

I know this question has already been answered, but I have had very good luck with Spring Boot.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.