-
Book Overview & Buying
-
Table Of Contents
Java Web Internals
By :
This book is born with a clear, yet challenging, proposition: to guide you through a complete journey of building a web framework from its most basic fundamentals. In a scenario where modern frameworks abstract almost all the complexity of web development, many developers end up using powerful tools without understanding what really happens behind the layers of abstraction. Here, we will take the opposite approach. Instead of starting at a high level, we will build this knowledge from the ground up, understanding each piece that makes up the web ecosystem.
Throughout my career as a university professor, I have always dedicated myself to teaching the fundamentals of Computer Science to my students. This has sparked in me, and in my students, a fascination with understanding technology beyond the surface.
And this subject was no different. Web development is currently much easier thanks to the frameworks available, especially considering the Java ecosystem.
However, web frameworks are nothing more than abstractions of something that has always existed in web specifications since their earliest versions. Today, when we use a framework like Spring or Quakus, for example, much of what we use is the result of abstraction layers that, in the past, we did almost manually.
Throughout this journey, you will be guided from the most fundamental concepts of network communication, through the use of sockets, to the implementation of a functional web server. This approach not only strengthens technical understanding but also allows you to develop a critical view of how distributed applications actually work. After all, every web application depends on clear rules of communication between client and server, based on well-defined protocols, as discussed throughout the book.
With this foundation established, we will move on to building an application server, significantly expanding our capabilities. Unlike a traditional web server, which only delivers static content, an application server is capable of executing business logic and generating dynamic responses based on received requests. This transition represents one of the most important moments in the book, as it's where we move from simply serving files to actually processing information and building complete applications.
To make this possible, a deep understanding of how the HTTP protocol works will be essential. Throughout the chapters, you will see how requests are structured, how responses are assembled, and how every detail – from headers to the message body – influences the application's behavior. More than just using HTTP, you will implement it in practice, understanding its nuances and limitations, which provides a much more solid mastery of web development.
All this construction will be done using Java, exploring everything from its most basic concepts to more advanced features. We will start with fundamental language structures and essential APIs, such as sockets and I/O, gradually evolving to the use of reflection, annotations, and architectural patterns that allow the creation of more sophisticated solutions. This progression was carefully planned to ensure that each new concept builds upon the previous one, creating a consistent and natural learning curve.
By the end of the journey, you will not only have built a functional web framework, but you will also have developed a deep understanding of how real frameworks operate internally. This means that when using tools like Spring, Quarkus, or any other modern framework, you will be able to see beyond the abstraction, understanding their design decisions, their strengths, and their limitations.
This book, therefore, is not just about writing code. It's about training a developer with a systemic vision, capable of understanding, building, and evolving solutions with autonomy and confidence. If you want to move beyond the superficial level and truly master the inner workings of web development, this journey is for you – and I hope you enjoy it!
This book is for computer science students and Java Web developers at all levels (junior to senior) who want to know more about Web fundamentals and explore framework internals. The main purpose of this book is to uncover some aspects of how a framework can abstract many communication issues and HTTP protocol manipulation, giving autonomy to developers to focus on business rules implementation.
Chapter 1, Networks, Protocols and Packets, introduces the fundamental concepts of network-based communication with a simple client/server calculator implementation.
Chapter 2, Workings of a Web Server – A Case Study, concerns the main aspects of web server internals, including how it handles the HTTP protocol, decodes requests, and generates responses in different media types.
Chapter 3, Implementing a Simple Web Server, shows, step by step, how to implement the full web server delivering static content.
Chapter 4, Web Servers vs Application Servers, discusses the main differences between static and dynamic content generation, and which aspects to evolve in the web server to create an application server.
Chapter 5, Deep dive into Simple Web Container implementation, explores not only the Application Server implementation, but also a minimal library to create an application that uses this Application Server as communication infrastructure.
Chapter 6, Simple Web Container improvements and expansions, creates a roadmap for expansions and improvements of our Web Container, including multithreading, logs, and so on.
Chapter 7, Why Create a Web Framework, discusses the motivation to develop a framework, which abstractions we can achieve with a framework, and how complex it is.
Chapter 8, Web Frameworks – The Necessary Abstraction for Professional Development, explains the whole framework architecture and needed components.
Chapter 9, Detailing the SimpleWebFramework Implementation, explores implementation details and project decisions to make a simple but functional web framework.
Chapter 10, The Emergence of Dependency Injection and its Application in SimpleWebFramework, discovers how a specification can be applied to our framework.
Chapter 11, Creating the First Application with SimpleWebFramework, explains how to create your web application using the developed web framework with all dependencies and make it functional.
The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Java-Web-Internals. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781835881484.
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: " Let us explore the definition of our Request class in this code snippet:"
A block of code is set as follows:
Class Request.java
public record Request(Double op1, Double op2, String oper) {
}
Any command-line input or output is written as follows:
javac -d bin *.java
Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: " To answer these questions, we will initially consider a "classical model" in the literature: the client-server communication model."
Warnings or important notes appear like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book or have any general feedback, please email us at customercare@packt.com and mention the book's title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packt.com/submit-errata, click Submit Errata, and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packt.com/.
Change the font size
Change margin width
Change background colour