Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SE - a small web server program

Tags:

java

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)

like image 644
Sam YC Avatar asked Aug 03 '12 16:08

Sam YC


People also ask

Does Java have a web server?

Java 18's Simple Web Server is a minimal HTTP static file server that was added in JEP 408 to the jdk. httpserver module.

Which web server is used for Java?

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.

What is the web server give example?

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.


1 Answers

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.

like image 67
jderda Avatar answered Sep 19 '22 23:09

jderda