Example application showing how to configure an embedded Jetty server to use in combination with an htmx web user interface via:
- Static files included in the resources
- REST APIs
- WebSocket communication
Full information is available here:
See https://eclipse.dev/jetty/.
"Jetty provides a web server and servlet container, additionally providing support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and are freely available for commercial use and distribution."
See https://htmx.org/ and https://htmx.org/extensions/web-sockets/.
"htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext"
- Random text output is generated with the Datafaker library.
- Open the project in your IDE as Maven project.
- Open
be.webtechie.javajettyhtmx.Application
. - Click on run on the
main
method. - Open the browser on one of these pages:
- Test the REST APIs:
- You can test the WebSocket on this endpoint:
ws://localhost:9999/websocket/ws
- Build the application with
mvn package
. - Start it with
java -jar target/jetty-htmx-demo.jar