📁 Java HTTP Server Project Documentation

Overview

This is a comprehensive, self-hosted multi-tenant web hosting platform built from scratch in Java. The system provides users with complete website hosting capabilities, including file management, database access, PHP execution, blog creation, and media streaming—all through an intuitive web-based interface.


Architecture

Backend (Java)


Frontend (JavaScript + PHP)


Database


Core Features

1. Multi-Tenant User Management


2. File Management System

Web-based File Explorer: Navigate directories, create folders, upload/download files

In-browser Code Editor: Edit HTML, CSS, JavaScript, and PHP files with syntax highlighting

File Type Support:

File Operations:


3. PHP Script Execution


4. Blog Creation System


5. Video Streaming


6. Database Management


7. Security Features


Technical Highlights

Multipart Form Data Parser


Virtual Host System


Content-Type Detection


Advanced Path Resolution

The RootHandler implements sophisticated fallback logic:

  1. Try exact file match
  2. Fall back to index.html
  3. Fall back to index.php
  4. Fall back to index.blog
  5. Serve 404 if nothing found

File Structure

/home/lukas/
├── users/
│   └── {username}/
│       ├── static/          # User's web-accessible files
│       │   ├── html/
│       │   ├── css/
│       │   ├── js/
│       │   ├── img/
│       │   └── php/
│       └── blog/            # Blog HTML files
├── JavaServerProject/
│   └── www/
│       └── static/          # Admin/default files
└── php_ini/
    └── {username}.ini       # Per-user PHP config

API Endpoints

The server exposes 20+ HTTP endpoints:

File Management:

Blog Management:

Authentication:

Database:

Utilities:


User Interface

The web interface (index.php) provides:


Performance Optimizations

  1. Thread Pool Sizing: Separate pools prevent blocking
  2. Stream Limiting: Prevents video streams from exhausting resources
  3. File Channel Streaming: Zero-copy file transfers for large files
  4. Lazy Loading: Files loaded on-demand, not preloaded
  5. Connection Limits: Configurable maximum concurrent streams (8 for video)
  6. Atomic Counter: Thread-safe stream tracking with AtomicInteger

Deployment


Use Cases

  1. Personal Web Hosting: Host your own websites and blogs
  2. Development Environment: Test and deploy web projects
  3. Client Hosting: Provide hosting services to multiple clients
  4. Educational Platform: Learn web development with real hosting environment
  5. Portfolio Hosting: Manage multiple portfolio sites under one server

Key Classes and Components

Handler Classes


Helper Methods


Frontend Modules

DocumentManager (docmanager.js)

Manages the user interface and file browser:


UploadManager (upmanager.js)

Handles file upload operations:


Security Considerations


Limitations and Known Issues


Future Enhancement Opportunities


Summary

This is a production-ready, feature-complete web hosting platform built entirely from scratch in Java. It demonstrates advanced Java networking, custom HTTP protocol handling, multipart form parsing, PHP CGI integration, and comprehensive file management—all wrapped in a user-friendly web interface built with vanilla JavaScript.

The multi-tenant architecture with per-user isolation makes it suitable for hosting multiple independent websites on a single server while maintaining security and resource boundaries. The system handles everything from static file serving to dynamic PHP execution, database management, blog publishing, and video streaming—providing a complete hosting solution without relying on traditional web servers like Apache or Nginx for core functionality.

With over 3000 lines of Java code and comprehensive JavaScript modules, this project represents a deep understanding of web protocols, server architecture, security principles, and full-stack development. It serves as both a functional hosting platform and a learning resource for understanding how web servers work at a fundamental level.