I am just curious how to implement a small server program in Java SE?
The program is listening on port 80 and ready to retrieve an InputStream object, but is there any function I can use to convert an InputStream into an HttpRequest object (something like Servlet)?
After that, how can I craft an HttpResponse object and send the data back to the browser?
Conclusively, I am just looking any framework that can help me parse the HTTP format into an object, or from an object into an HTTP response stream.
(I know Java EE will be the better solution, I just want to test something on Java SE)
Java 18's Simple Web Server is a minimal HTTP static file server that was added in JEP 408 to the jdk. httpserver module.
Apache Tomcat One of the more popular web servers in the Java ecosystem is Apache Tomcat. You can check the latest version of Apache Tomcat and the support Java version(s) on the project's website.
On the hardware side, a web server is a computer that stores web server software and a website's component files (for example, HTML documents, images, CSS stylesheets, and JavaScript files). A web server connects to the Internet and supports physical data interchange with other devices connected to the web.
Look no further than Jetty in this case. It is written for exactly that purpouse - embedding an HTTP server into your application. But probably won't get you an HttpRequest object, but perhaps something similar that should suit your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With