Coder Social home page Coder Social logo

webserver's Introduction

WebServer

Installation

Run gradle build

.\gradlew.bat clean build

This will generate jar file under build\libs directory

Usage

Run the Java jar file

java -jar build\libs\webserver-1.0-SNAPSHOT.jar

And the server load prints

Starting app on directory: C:\Users\[User]\Projects\webserver
Starts web server on port: 80

Open web browser and load localhost

http://localhost

it will print the listing of application run directory e.g. C:\Users[User]\Projects\webserver.

I prepared test directory public/ which contains index.html. You can change into this directory before running the server to test how the webserver responds with html content by clicking index.html link when directory listing is loaded.

Design decision

JDK/JRE: Adopt OpenJDK v11 (OpenJ9)

Due to limitation of using only standard Java SE 8:

  1. Use combination of ServerSocket and BufferedReader to process incoming request to port 80.
  2. Use combination of BufferedWriter and StringBuilder to generate response.
  3. Build own HTTPStatus class using Map, currently only HTTP status 200, 404 and 500 included.

Future improvements

  1. Break main method to process request separately.
  2. Add configuration for port, serving directory.
  3. Complete HTTP error status.
  4. Add unit tests.
  5. Use Threading and Non blocking IO.

webserver's People

Contributors

krishnasilalahi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.