There’s a lot of gold in them thar hills and gold can symbolize the value of knowledge. The Java servlet service method teaches us all about the http request and response objects, or HTTP Protocol and also about the client server paradigm. We learn about REST get and post, we learn about the client-server model which dates back to the arpanet days. We also learn about the javascript Fetch API. By studying these fundamentals we gain an understanding of the architecture behind web enabled networks. We request something on the client end and the server sends back a response. It is this way no matter what programming language we learn.
But Java is special to me because we can also learn quickly abut SQL by using the JDBC API inside a servlet. We import the java.sql package into our program and connect to a database so we can manipulate the data and thus create some logic for our web app development. I like to embed an SQLite db into my java project for this part. In quite a short time we can be up and running with our own http server hosted at a local host. The servlet is actually a compact web server because it accepts requests via HTTP (hypertext transfer protocol).
I use an Apache httpd component which serves up an HTML web page and also proxies to a Tomcat servlet server. BTW, I just described server side architecture. We can graduate to serverless architecture by using the JS Fetch API (http client) to execute an AWS Lambda function instead of a java servlet, thereby eliminating java and all our servers. In AWS we have an API Gateway (http server) that uses REST architecture. My data is stored in an array in JSON format on AWS S3. Instead of sql this is a nosql approach where we use front-end JS array methods to manipulate the data.
Now u can see that just by understanding fundamentals from the Java servlet we can also understand the server architecture and the serverless architecture too. Servless still uses request and response, Fetch is the javascript request and json rendered in html is the response object.
Think for a moment what topics we covered here just by reviewing the guts of a java servlet, all this valuable knowledge. We don’t have to stay with java, knowing the java servlet api just helps immensely to provide a basic understanding of dynamic web development and programming logic.
Topics covered:
HTTP
HTML
Server architecture, Apache and Tomcat
Plain JS
Javascript Fetch api or axios, our http client
REST
JDBC
SQL, collections of data
SQLite
noSQL
JSON, array
Javascript array methods
Web dev - combine all these topics and u have fundamentals of web development.
Serverless architecture using AWS Lambda instead of Java (only for limited use cases)
So go out and brush up ur skills, broaden ur horizons to increase ur net worth.
This is all for now folks, we just want to get our feet wet by understanding the why, then it will be time to explore more about the how to. Original content supporting this article can be found at my website https://howtolearnjava.com. My teaching methodology is to provide ready made java class files that u can just copy and paste into a Spring STS dynamic web project. There are enough comments in these class files designed to guide u thru the learning process.
About the author Rick Delpo. Do a google search on Rick Delpo to find out more about Java servlets and JDBC.
Happy Coding !!
Top comments (0)