-
Book Overview & Buying
-
Table Of Contents
Java Web Internals
By :
How do you implement a SimpleWebContainer (SWC) from the WebServer we already have? We will answer this question throughout this chapter.
Initially, our SimpleWebServer is only responsible for delivering static content, that is, reading the bytes of a file and sending them in an HTTP response. The files we handle, in this case, are files that have the following extensions: HTML, HTM, CSS, JS, PNG, JPG, ICO, and TXT. These types of files will only be read and their contents sent according to their media type (Mime Type), so that the browser knows how to display them in the end. Obviously, you can expand this list of files to your needs, such as PDF, ZIP, MP3, AVI, MP4, etc. Regardless of this expansion, the process is the same: search for the file, read its content in bytes, send the response to the browser. If the file is not found, we issue an HTTP 404 error.
In the case of executing Java classes, we first need to have an initial search...