simple HTTP server in Java using only Java SE API

前端 未结 17 2019
无人共我
无人共我 2020-11-22 13:28

Is there a way to create a very basic HTTP server (supporting only GET/POST) in Java using just the Java SE API, without writing code to manually parse HTTP requests and man

17条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 14:15

    You can write a pretty simple embedded Jetty Java server.

    Embedded Jetty means that the server (Jetty) shipped together with the application as opposed of deploying the application on external Jetty server.

    So if in non-embedded approach your webapp built into WAR file which deployed to some external server (Tomcat / Jetty / etc), in embedded Jetty, you write the webapp and instantiate the jetty server in the same code base.

    An example for embedded Jetty Java server you can git clone and use: https://github.com/stas-slu/embedded-jetty-java-server-example

提交回复
热议问题