<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Samuel Owino on Medium]]></title>
        <description><![CDATA[Stories by Samuel Owino on Medium]]></description>
        <link>https://medium.com/@samuelowino?source=rss-a431223b6be9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*r3V16j07gOjkBew0pq_LuQ.jpeg</url>
            <title>Stories by Samuel Owino on Medium</title>
            <link>https://medium.com/@samuelowino?source=rss-a431223b6be9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 05:15:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samuelowino/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deep Dive Into Java Collections]]></title>
            <link>https://samuelowino.medium.com/deep-dive-into-java-collections-31dcaa9befe2?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/31dcaa9befe2</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 16:35:05 GMT</pubDate>
            <atom:updated>2026-07-14T16:35:05.957Z</atom:updated>
            <content:encoded><![CDATA[<p>Java is now over 31 years old but the collections framework is not quite as old as Java, it is almost 30 years old (28 years old as of 2026).</p><p>Java 1.0 was introduced with what is now called <strong>legacy collections</strong>. (<strong>Vector, HashTable, Enumeration, Dictionary </strong>and <strong>Stack.</strong></p><p>These <strong>legacy collections </strong>where replaced in<strong> JDK 1.2</strong>, which is the collections framework that we are all familiar with, with the interfaces <strong>Collection, List, Set, Map, Comparable, Comparator </strong>and the concrete classes to back them up; <strong>ArrayList, HashMap, HashSet, TreeSet, TreeMap </strong>and so forth.</p><p>These were introduced in 1998 which is 28 years ago as of 2026.</p><p>These collections are in use daily.</p><p>A paper published in 2017 found that ArrayList is the most used collection in Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DW7Tfx6XQVfSGWWeYVbiGA.png" /><figcaption>Empirical Study of Usage and Performance of Java collections <a href="https://research.spec.org/icpe_proceedings/2017/proceedings/p389.pdf">https://research.spec.org/icpe_proceedings/2017/proceedings/p389.pdf</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibzLLuXjciEB48TchOzWag.png" /><figcaption>Collection Usage in Real Code. Excerpt from the Paper: Empirical Study of Usage and Performance of Java Collections:<a href="https://research.spec.org/icpe_proceedings/2017/proceedings/p389.pdf">https://research.spec.org/icpe_proceedings/2017/proceedings/p389.pdf</a></figcaption></figure><p>In Java 5 in 2004 <strong>generics</strong> were added to the language and that had a huge impact on the collections APIs. It is expected that by now everyone has converted over to using genericized collections instead of the original raw collections.</p><p>The other big addition in Java 5 is <strong>Concurrent Collections.</strong></p><p>Along the way various individual implementations were added in various releases such as <strong>ArrayDeque, PriorityQueue, EnumMap, IdentityHashMap, LinkedHashMap </strong>and <strong>WeakHashMap.</strong></p><h4><strong>Java 8 Collections Enhancements</strong></h4><p>Most people are aware that the big features of Java 8 are; <strong>lambdas</strong> and <strong>the Streams API. </strong>These are very interesting features that are very useful and its expected that every Java developer is using them.</p><p>Backing up these new features in Java 8 are some additional language features in particular <strong>interfaces </strong>can now have <strong>default methods, </strong>and <strong>static methods.</strong></p><p>These are very interesting language features but will not talk about the language enhancements themselves instead in this article we will talk about how these language features are used in the JDK to enhance the collections framework.</p><p>For the first time ever, methods were added to the <strong>Collections interfaces. </strong>This was the big deal about <strong>default methods in interfaces as a feature, </strong>prior to Java 8 <strong>default methods </strong>you could not compatibly add methods to interfaces otherwise it would be an incompatibility. So, in Java 8 with the addition of default methods it was no possible to add methods to interfaces and the JDK team went ahead and did so.</p><p><strong>Iterable, Collection </strong>and <strong>List </strong>interfaces go new methods.</p><p><strong>Map </strong>and <strong>Comparator </strong>also got a bunch of new methods.</p><p>A lot of these new methods were added from the standpoint of the capabilities of <strong>lambdas. </strong>When these new methods are able to accept a lambda, they can do much more powerful things.</p><h4>Iterable Interface</h4><p>The iterable interface has been there since Java 5.</p><p>The interface basically allows you to use the enhanced <strong>for loop.</strong></p><p>In Java 7 if you wanted to iterate over a list you could use the <strong>enhanced for loop </strong>but in Java 8 the forEach method and pass it a lambda and it will execute that lambda on each element in that list.</p><pre>// Java 7 | Before Java 8<br>List&lt;String&gt; list = new ArrayList&lt;&gt;();<br>for (String str : list) {<br>  System.out.println(str);<br>}<br><br>// After Java 7<br>List&lt;String&gt; list = new ArrayList&lt;&gt;();<br>list.forEach(IO::println);</pre><p>Iterable is inherited by every collection implementations, therefore all collections are enhance by having this forEach method on them. Indeed, all the other default methods are inherited all the way down the hierarchy. By adding default methods the JDK team is able to enhance every existing collection even the one’s that were introduced prior to Java 8.</p><p>If you’ve ever written an iterator you had to write a hasNext method and next method and the remove method and if you did not want to support removal, you would write throw UnsupportedOperationException .</p><pre>class MyIterator&lt;T&gt; implements Iterator&lt;T&gt; {<br>  private final T[] elements;<br>  private int index = 0;<br>  public MyIterator(T[] values) {<br>    this.elements = values;<br>  }<br>  @Override <br>  public boolean hasNext() {<br>    return index &lt;= elements.length;<br>  }<br>  @Override<br>  public T next() {<br>    var value = elements[index];<br>    index += 1;<br>    return value;<br>  }<br>  @Override<br>  public void remove() {<br>    throw new UnsupportedOperationException();<br>  }<br>}</pre><p>So, now there is a default method on the <strong>Iterator </strong>interface called remove with a default implementation that throws UnsupportedOperationException . If you are writing your own iterator and don’t override remove, you get default behaviour which is to throw the exception UnsupportedOperationException .</p><pre>class MyIterator&lt;T&gt; implements Iterator&lt;T&gt; {<br>  private final T[] elements;<br>  private int index = 0;<br>  public MyIterator(T[] values) {<br>    this.elements = values;<br>  }<br>  @Override <br>  public boolean hasNext() {<br>    return index &lt;= elements.length;<br>  }<br>  @Override<br>  public T next() {<br>    var value = elements[index];<br>    index += 1;<br>    return value;<br>  }<br>}</pre><p>But it you do want to support removal in your iterator, you just go ahead and override remove like it was prior to default methods.</p><pre>class MyIterator&lt;T&gt; implements Iterator&lt;T&gt; {<br>  private final T[] elements;<br>  private int index = 0;<br>  public MyIterator(T[] values) {<br>    this.elements = values;<br>  }<br>  @Override <br>  public boolean hasNext() {<br>    return index &lt;= elements.length;<br>  }<br>  @Override<br>  public T next() {<br>    var value = elements[index];<br>    index += 1;<br>    return value;<br>  }<br>  @Override<br>  public void remove() {<br>    // your custom implementation of remove<br>  }<br>}</pre><h4>Collection.removeIf</h4><p>Suppose you have a case where you want to run through a list and remove elements that match some criteria. In Java 7, you have to write it out the old way using an iterator.</p><pre>// Java 7 <br>for (Iterator&lt;String&gt; it = coll.iterator(); it.hasNext(); ) {<br>  String str = it.next();<br>  if (str.startsWith(&quot;A&quot;))<br>    it.remove();<br>}</pre><p>The key point here is in Java 7 you could not use the enhanced for loop because you can’t remove things from within a loop otherwise you would get a ConcurrentModificationException . So, what you had to do was fallback to the original for-loop, loop using an iterator and then if something matched call the remove() on the iterator.</p><p>This is very bulky even compared to the enhanced for-loop code that you would write if you were not removing anything.</p><p>In Java 8 a new method was added removeIf(predicate) that takes a predicate and the semantics are, that predicate is applied to each element of that collection and if the predicate returns true then it removes it from the collection. This is pretty nice because a 4 of 5 line for-loop is collapsed into just one line.</p><pre>// Java 8 <br>collection.removeIf(str -&gt; str.startsWith(&quot;A&quot;));</pre><p>It’s not only a syntactic advantage it’s actually a performance advantage.</p><p>If you consider iterating over an ArrayList if you remove something from an ArrayList it has to shift all elements up in place and if you do that repeatedly within an ArrayList you get an O(n^2) performance because it is repeatedly shifting the tail of the ArrayList back up as elements are deleted.</p><p>removeIf in Java 8 is optimised for ArrayList because it keeps track of which elements are removed and does the copy-in operation all at once. This reduces the algorithm performance from O(n^2) to O(n) at the same time, the Java 8 version also makes the code more concise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LpeEobYbaUxabM_y8WIWAg.png" /><figcaption>Removing from ArrayList shifts elements every time remove(index) happens</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pp7OIwtbT6xqHXH7csQ5aA.png" /><figcaption>Screen grab from Stuart Marks’s talk : Collections Refuelled Available on YouTube <a href="https://youtu.be/q6zF3vf114M?si=0iWiKV2IlYTP2CcD">https://youtu.be/q6zF3vf114M?si=0iWiKV2IlYTP2CcD</a></figcaption></figure><p>The benefit here is that the removeIf operation has raised the semantic level of the API, so instead of looking at the collection from the outside and processing each element at a time, we can now remove all matching elements and the implementation takes advantage of this abstraction with a better more performant algorithm.</p><h4>List.replaceAll</h4><p>The List Interface has a couple new methods on it, one of them is replaceAll and what that does is, it replaces every element in the list with something else.</p><p>Suppose you wanted to do that in Java 7, you could use the original style of for-loop using a listIterator .</p><pre>// Java 7 <br>for (ListIterator&lt;String&gt; it = list.listIterator() ; it.hasNext() ; ) <br>    it.set(it.next().toUpperCase());</pre><p>In this example, we are running through a list of string and convert them all toUpperCase . You could run a ListIterator over the list and set each element to the element converted to upperCase .</p><p>Most people however do not use ListIterator .</p><p>You can also index the list and just call get() and set() .</p><pre>// Java 7 alt<br>for (int i = 0; i &lt; list.size(); i++) <br>    list.set(i, list.get(i).toUpperCase());</pre><p>Most people would probably write it this way which is perfectly fine if you know you are operating on an ArrayList but if you are using a LinkedList that will slow down your program drastically.</p><p>In Java 8 this gets even better because we just call list.replaceAll(UnaryOperator) . UnaryOperator here being the operator (lambda or method reference) that we apply to each element.</p><pre>default void replaceAll(UnaryOperator&lt;E&gt; operator) {<br>    Objects.requireNonNull(operator);<br>    final ListIterator&lt;E&gt; li = this.listIterator();<br>    while (li.hasNext()) {<br>        li.set(operator.apply(li.next()));<br>    }<br>}</pre><pre>// Java 8 <br>list.replaceAll(String::toUpperCase);</pre><p>In one line, we have managed to replace Java 7 style loops that did things one-at-time.</p><p>You cannot convert elements into a new type because the UnaryOperator only supports processing elements and returning values of the same type.</p><pre>@FunctionalInterface<br>public interface UnaryOperator&lt;T&gt; extends Function&lt;T, T&gt; {<br>    static &lt;T&gt; UnaryOperator&lt;T&gt; identity() {<br>        return t -&gt; t;<br>    }<br>}</pre><p>To transform elements into values of a different type you will need to use Stream and collect them into a new list with different types of elements.</p><h4>List.sort</h4><p>The Collection.sort method has to operate on any implementation of list and the most generic way of doing that is to copy elements into a temporary Array that is temporarily allocated just for the purpose of sorting. The Array would be sorted in place and the elements would then be copied back to the original list.</p><p>The default implementation of List.sort does exactly this because it doesn’t know who it is inherited by.</p><pre>// java.util.List<br>@SuppressWarnings(&quot;unchecked&quot;)<br>default void sort(Comparator&lt;? super E&gt; c) {<br>    Object[] a = this.toArray();<br>    Arrays.sort(a, (Comparator) c);<br>    ListIterator&lt;E&gt; i = this.listIterator();<br>    for (Object e : a) {<br>        i.next();<br>        i.set((E) e);<br>    }<br>}</pre><p>However, ArrayList.sort overrides the default implementation and instead sorts the elements in place.</p><pre>// java.util.ArrayList.java<br>@Override<br>public void sort(Comparator&lt;? super E&gt; c) {<br>    sortRange(c, 0, size);<br>    modCount++;<br>}<br>@SuppressWarnings(&quot;unchecked&quot;)<br>private void sortRange(Comparator&lt;? super E&gt; c, int fromIndex, int toIndex) {<br>    final int expectedModCount = modCount;<br>    Arrays.sort((E[]) elementData, fromIndex, toIndex, c);<br>    if (modCount != expectedModCount)<br>        throw new ConcurrentModificationException();<br>}</pre><p>In turn Collections.sort will call sort on the list implementation it’s provided which would be ArrayList.sort in this case. If your code is using ArrayList and you call Collections.sort you get this new behaviour for free.</p><h4>Map : forEach</h4><p>In Java 7 if you wanted to do something for every element of the map, like print out each key and value, you’d loop over the entrySet of the map and then do your operation inside that for-loop.</p><pre>// Java 7<br>for (Map.Entry&lt;String, String&gt; entry : map.entrySet()) <br>      entry.setValue(entry.getValue().toUpperCase());</pre><p>In Java 8 there is a forEach(BiFunction) that takes a BiFunction that takes two arguments, the key and the value , so you can write a lambda expression that does that.</p><p>Instead of you having to iterate over the map entries and then do getKey() and getValue() , it just hands you the key and the value separately.</p><pre>@FunctionalInterface<br>public interface ToIntBiFunction&lt;T, U&gt; {<br>    int applyAsInt(T t, U u);<br>}</pre><pre>map.forEach((k,v) -&gt; IO.println(&quot;key &quot; + k + &quot;value &quot; + v ));</pre><p>The Java 8 is much more convenient in that way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31dcaa9befe2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Case for Individualism over Collectivism]]></title>
            <link>https://samuelowino.medium.com/the-case-for-choosing-individualism-over-collectivism-dd8de00c6037?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd8de00c6037</guid>
            <category><![CDATA[individualism]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[collectivism]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Sat, 30 May 2026 20:55:22 GMT</pubDate>
            <atom:updated>2026-05-30T20:55:43.385Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*bIv4mRrZMybW_zG9CT4GQA.png" /><figcaption><a href="https://oll.libertyfund.org/people/ludwig-von-mises">Ludwig von Mises | Online Library of Liberty</a></figcaption></figure><p>Philosophers have long debated over whether it is the collective or the individual who should be viewed as superior and of more value, but rarely has a consensus been met.</p><p>This unresolved debate is important because the prevailing views on this issue often determine how a society organises itself and thus the quality of life for its citizens.</p><p>In this article we are going to examine a critic of collectivism by one of the most prolific philosophers of the 20th century, Ludwig von Mises.</p><p>Mises was born in 1881 in the Austria — Hungarian empire, and is best known for this contributions to the field of economics, however he also made important contributions to many other fields including epistemology, ethics, political philosophy, social theory and history.</p><p>Throughout his life Mises always showed a concern for defending individual freedoms as he saw them as essential for lasting peace and prosperity. Consequently he was always concerned with combating collectivism.</p><p>The meanings of the terms collectivism and individualism like many of the terms used in political discourse are quite ambiguous. However, when discussing them the issue which is usually of most concern is whether the goals of the collective should be seen as more important than the goals of the individual, which would be the collectivist position or whether the goals of the individual should be viewed as supreme the individualist position.</p><p>Integral to Mises’ critic of the collectivist position was methodological individualism a doctrine which holds that only individuals act. To Mises the truth of this was obvious, only individuals act and any action by a collective can ultimately be reduced to the actions of various individuals.</p><p>In the ultimate foundations of economic science, Mises has this to say about methodological individualism.</p><p>“In denying independent existence of their own to the collectives one does not in the least deny the reality of the effects brought about by the cooperation of the individuals, one merely establishes the fact that the collectives come into being by the thought of the individuals and that they disappear when the individuals adopt a different way of thinking and acting.”</p><p>While not denying the existence of collectives, methodological individualism denies the ability of any collective to exist in an autonomous manner independent of the individuals who compose it.</p><p>Mises’ stressed the importance of methodological individualism because he believed that often people who favour the collectivists position will try to assert some form of independent existence to their collective in order to justify the elevation of its goals.</p><p>Mises has two main criticisms for those who want to elevate the supposed goals of a collective above those of the individual.</p><p>Firstly Mises stressed a point which is easily overlooked, that being that the creation of a collective is always arbitrary, in other words because collectives virtual never include the entirety of mankind, criteria must be established to distinguish between who is to be included and who excluded from the collective, but there is no set way to determine such criteria, and this is why throughout history collectives have taken so many forms. Whether it be collectives determined by race, religion, wealth or country of birth.</p><p>As such, at any given time there always exists a plurality of collectives, and each collective believes their goals are superior, not only to those of the individual but also those of all rival collectives.</p><p>In his work, <strong>Theory and History</strong>, Mises emphases this point by saying</p><p>“There is no uniform collectivists ideology but many collectivist doctrines each of them extols a different collectivist entity and requests all decent people to submit to it. Each sect worships its own idol and is intolerant of all rival idols.”</p><p>The second criticism Mises put fourth was that the goals which are elevated over those of the individual are never actually the goals of an autonomous collective as no such thing exists, but rather are merely the goals of those who exert power or influence over the collective at any given point in time. Mises believed that this is why countries that become increasingly collective also become increasingly unstable.</p><p>As he puts it in his monumental work, <strong>Human Action</strong>:</p><p>“It is true that every variety of collectivisms promises eternal peace starting with the day of its own decisive victory, however the realisation of these plans is conditioned upon a radical transformation in mankind. Man must be divided into two classes; the omnipotent god-like dictator on one the hand and the masses which must surrender volition and reasoning in order to become mere chessmen in the plans of the dictator. There is no need to point out that such designs are unrealisable.”</p><p>In opposition to collectivist doctrines, Mises was in favour of individualism, or in other words, the ability of each individual to choose his or her own goals and act accordingly, whether that led to the starting of a charity to help the poor, working construction or just sitting on the couch all day to contemplate the meaning of life. However, in executing one’s plans Mises believed that each individual should respect the rights and freedoms of others.</p><p>It is important to stress that Mises did not promote individualism because he was somehow against society or other collective entities, rather his strong support for individualism was based on his belief that the individualist position was essential for longterm peace and prosperity.</p><p>Mises believed that when individuals work to achieve their own goals, they readily recognise the mutual benefits that arise from cooperation, voluntary exchange and the division of labour, and that these social phenomena are not at all incompatible with the individualist position but rather incompatible with collectivism.</p><p>Mises conveys this by saying:</p><p>“The customary terminology misrepresents these things entirely. The philosophy commonly called individualism is a philosophy of social cooperation and the progressive intensification of the social nexus. On the other hand the application of the basic idea of collectivism cannot result in anything but social disintegration and the perpetuation of armed conflict.”</p><p>Another philosopher who was strongly against the collectivism but likely for different reasons was Fredrick Nietzsche.</p><p>Nietzsche believed that only autonomous individuals are of any worth and that those who are bound up in the ideals and goals of a collective or what he called the herd are really individuals too weak to create their own goals and meaning for life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KROQum086EXgt3nM80MXtQ.jpeg" /><figcaption>Friedrich Nietzsche | Wikipedia</figcaption></figure><p>To conclude this article we will quote a short passage by Nietzsche from his work <strong>Thus Spoke Zarathustra which in a much different style puts fouth a somewhat similar view as that of Mises.</strong></p><p>“Somewhere there ares still peoples and herds but not where we live my brothers: here there are states. State? What is that? Well then open your ears to me, for now I shall speak to you about the death of peoples. State is the name of the coldest of all cold monsters. Coldly it tells lies too; and this lie crawls out of its mouth: “I, the state, am the people.” That is a lie! Behold, how it lures them, the all-too-many-and how it devours them, chews them and ruminates…”</p><p>If you enjoyed reading this article take a moment and checkout my work on Life Planner here <a href="https://thelifeplanner.co/download">thelifeplanner.co/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd8de00c6037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jakarta Servlets 6.1 : On HttpServlet]]></title>
            <link>https://medium.com/javarevisited/jakarta-servlets-6-1-on-httpservlet-d9d5da01c9fd?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9d5da01c9fd</guid>
            <category><![CDATA[servlet]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Wed, 27 May 2026 13:44:48 GMT</pubDate>
            <atom:updated>2026-05-29T10:18:18.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCflA8LdU6w3qVQDGiboiw.png" /><figcaption>Screen grab of IntelliJ IDEA</figcaption></figure><p>Jakarta Servlets are regular Java objects that enable web applications to receive and process requests from clients. Servlets depend on servlet engines such as Tomcat to receive and route requests to parts of your Java application that can actually process the client’s requests.</p><p>The servlet interface that is defined in the Jakarta servlets specification is a regular Java interface that declares abstract methods to describe how a Java application will or should process a request originating from a client.</p><pre>public interface Servlet {<br><br>}</pre><p>The most popular implementations of the Servlet specification are <strong>Generic Servlet </strong>and <strong>HttpServlet.</strong></p><p>Generic servlet implements the Servlet interface, which means it adds definitions to most of the interface’s abstract functions while leaving some functions abstract for upstream implementors of the interface to complete.</p><pre>public abstract class GenericServlet implements Servlet {<br>    @Override<br>    public void destroy() {<br>    }<br>    @Override<br>    public String getInitParameter(String name) {<br>        ServletConfig sc = getServletConfig();<br>        if (sc == null) {<br>            throw new IllegalStateException(lStrings.getString(&quot;err.servlet_config_not_initialized&quot;));<br>        }<br><br>        return sc.getInitParameter(name);<br>    }<br>    @Override<br>    public Enumeration&lt;String&gt; getInitParameterNames() {<br>        ServletConfig sc = getServletConfig();<br>        if (sc == null) {<br>            throw new IllegalStateException(lStrings.getString(&quot;err.servlet_config_not_initialized&quot;));<br>        }<br><br>        return sc.getInitParameterNames();<br>    }<br>    @Override<br>    public ServletConfig getServletConfig() {<br>        return config;<br>    }<br>    @Override<br>    public ServletContext getServletContext() {<br>        ServletConfig sc = getServletConfig();<br>        if (sc == null) {<br>            throw new IllegalStateException(lStrings.getString(&quot;err.servlet_config_not_initialized&quot;));<br>        }<br><br>        return sc.getServletContext();<br>    }<br>    @Override<br>    public String getServletInfo() {<br>        return &quot;&quot;;<br>    }<br>    @Override<br>    public void init(ServletConfig config) throws ServletException {<br>        this.config = config;<br>        this.init();<br>    }<br>    @Override<br>    public abstract void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;<br>    @Override<br>    public String getServletName() {<br>        ServletConfig sc = getServletConfig();<br>        if (sc == null) {<br>            throw new IllegalStateException(lStrings.getString(&quot;err.servlet_config_not_initialized&quot;));<br>        }<br><br>        return sc.getServletName();<br>    }<br>}<br>}</pre><p>Generic servlet does not require conformance to any network protocols such as UDP, TCP or HTTP it mealy defines a servlet capable of receiving a request that has been routed from a servlet container.</p><p>The class that extends the <strong>GenericServlet</strong> abstract class is responsible for implementing the <strong>service() method, </strong>which means they will be responsible for what happens right after the servlet engine routes an incoming client request to this servlet.</p><p>HttpServlet is an abstract class that extends the Generic servlet class, which means HttpServlet also (indirectly) implements the Servlet interface and thus also provides an implementation of the Jakarta Servlet specification.</p><pre>public abstract class HttpServlet extends GenericServlet { <br><br>}</pre><p>HttpServlet defines a servlet that conforms to the HTTP specification, which means servlets that inherit from HttpServlet will define components and behaviour that match the HTTP specification.</p><p>For example, unlike <strong>GenericServlet</strong>, <strong>HttpServlet</strong> contains implementations of the HTTP request methods; <strong>GET, PUT, POST, DELETE, HEAD, TRACE, OPTIONS,</strong> as defined in the HTTP specification.</p><pre>public abstract class HttpServlet extends GenericServlet {<br>    private static final String METHOD_DELETE = &quot;DELETE&quot;;<br>    private static final String METHOD_HEAD = &quot;HEAD&quot;;<br>    private static final String METHOD_GET = &quot;GET&quot;;<br>    private static final String METHOD_OPTIONS = &quot;OPTIONS&quot;;<br>    private static final String METHOD_PATCH = &quot;PATCH&quot;;<br>    private static final String METHOD_POST = &quot;POST&quot;;<br>    private static final String METHOD_PUT = &quot;PUT&quot;;<br>    private static final String METHOD_TRACE = &quot;TRACE&quot;;<br>}</pre><p>HttpServlet also contains support for HTTP headers such as <strong>LAST-MODIFIED </strong>and <strong>IF-MODIFIED-SINCE </strong>headers<strong>.</strong></p><pre>public abstract class HttpServlet extends GenericServlet {<br>    private static final String HEADER_IFMODSINCE = &quot;If-Modified-Since&quot;;<br>    private static final String HEADER_LASTMOD = &quot;Last-Modified&quot;;<br>    // Add headers in lower case as HTTP headers are case insensitive<br>    private static final List&lt;String&gt; SENSITIVE_HTTP_HEADERS = <br>            Arrays.asList(<br>              &quot;authorization&quot;, <br>              &quot;cookie&quot;, &quot;x-forwarded&quot;, <br>              &quot;forwarded&quot;, &quot;proxy-authorization&quot;<br>            );<br>}</pre><p>HttpServlet implements the key entry point for all servlets, that is, the <strong>service()</strong> method which the servlet container will invoke to route incoming requests to the servlet.</p><pre>public abstract class HttpServlet extends GenericServlet {<br>    @Override<br>    public void service(ServletRequest req, ServletResponse res) {<br>        HttpServletRequest request;<br>        HttpServletResponse response;<br>    <br>        if (!(req instanceof HttpServletRequest &amp;&amp; res instanceof HttpServletResponse)) {<br>            throw new ServletException(&quot;non-HTTP request or response&quot;);<br>        }<br>    <br>        request = (HttpServletRequest) req;<br>        response = (HttpServletResponse) res;<br>    <br>        service(request, response);<br>    }<br>}</pre><p>Within the <strong>service() method</strong> in the HttpServlet there exists logic that checks the <strong>http method </strong>in the Http request and delegates processing to the matching http related function.</p><pre>protected void service(HttpServletRequest req, HttpServletResponse resp) {<br>    String method = req.getMethod();<br>    if (method.equals(METHOD_GET)) {<br>        doGet(req, resp);<br>    } else if (method.equals(METHOD_HEAD)) {<br>        doHead(req, resp);<br>    } else if (method.equals(METHOD_POST)) {<br>        doPost(req, resp);<br>    } else if (method.equals(METHOD_PUT)) {<br>        doPut(req, resp);<br>    } else if (method.equals(METHOD_DELETE)) {<br>        doDelete(req, resp);<br>    } else if (method.equals(METHOD_OPTIONS)) {<br>        doOptions(req, resp);<br>    } else if (method.equals(METHOD_TRACE)) {<br>        doTrace(req, resp);<br>    } else if (method.equals(METHOD_PATCH)) {<br>        doPatch(req, resp);<br>    } else {<br>        //<br>        // Note that this means NO servlet supports whatever<br>        // method was requested, anywhere on this server.<br>        //<br>        resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, <br>          &quot;http.method_not_implemented&quot;);<br>    }<br>}</pre><p>The methods in the HttpServlet that map to http methods defined in the http specification are the following:</p><p><strong>doGet — </strong>will handle <strong>HTTP GET</strong></p><pre>protected void doGet(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doPut — </strong>will handle <strong>HTTP PUT</strong></p><pre>protected void doPut(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doPost — </strong>will handle <strong>HTTP POST</strong></p><pre>protected void doPost(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doDelete — </strong>will handle <strong>HTTP DELETE</strong></p><pre>protected void doDelete(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doHead — </strong>will handle <strong>HTTP HEAD</strong></p><pre>protected void doHead(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doOptions — </strong>will handle <strong>HTTP OPTIONS</strong></p><pre>protected void doOptions(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p><strong>doTrace — </strong>will handle <strong>HTTP TRACE</strong></p><pre>protected void doTrace(HttpServletRequest req, HttpServletResponse resp) {<br>    <br>}</pre><p>It’s important to note that most of these methods only have one default behaviour which is to send a <strong>HTTP METHOD NOT ALLOWED 405 </strong>to the client.</p><p>You have to provide the request handling code for the http methods you decide to support in your own http servlet implementations.</p><p>Methods such as <strong>HTTP TRACE</strong> and <strong>OPTIONS </strong>have predefined functionality within http servlet that you can inherit.</p><pre>protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {<br>    Method[] methods = getAllDeclaredMethods(this.getClass());<br><br>    boolean ALLOW_GET = false;<br>    boolean ALLOW_HEAD = false;<br>    boolean ALLOW_POST = false;<br>    boolean ALLOW_PATCH = false;<br>    boolean ALLOW_PUT = false;<br>    boolean ALLOW_DELETE = false;<br>    boolean ALLOW_TRACE = true;<br>    boolean ALLOW_OPTIONS = true;<br><br>    for (int i = 0; i &lt; methods.length; i++) {<br>        String methodName = methods[i].getName();<br><br>        if (methodName.equals(&quot;doGet&quot;)) {<br>            ALLOW_GET = true;<br>            ALLOW_HEAD = true;<br>        } else if (methodName.equals(&quot;doPost&quot;)) {<br>            ALLOW_POST = true;<br>        } else if (methodName.equals(&quot;doPut&quot;)) {<br>            ALLOW_PUT = true;<br>        } else if (methodName.equals(&quot;doDelete&quot;)) {<br>            ALLOW_DELETE = true;<br>        } else if (methodName.equals(&quot;doPatch&quot;)) {<br>            ALLOW_PATCH = true;<br>        }<br><br>    }<br><br>    // we know &quot;allow&quot; is not null as ALLOW_OPTIONS = true<br>    // when this method is invoked<br>    StringBuilder allow = new StringBuilder();<br>    if (ALLOW_GET) {<br>        allow.append(METHOD_GET);<br>    }<br>    if (ALLOW_HEAD) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_HEAD);<br>    }<br>    if (ALLOW_PATCH) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_PATCH);<br>    }<br>    if (ALLOW_POST) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_POST);<br>    }<br>    if (ALLOW_PUT) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_PUT);<br>    }<br>    if (ALLOW_DELETE) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_DELETE);<br>    }<br>    if (ALLOW_TRACE) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_TRACE);<br>    }<br>    if (ALLOW_OPTIONS) {<br>        if (allow.length() &gt; 0) {<br>            allow.append(&quot;, &quot;);<br>        }<br>        allow.append(METHOD_OPTIONS);<br>    }<br><br>    resp.setHeader(&quot;Allow&quot;, allow.toString());<br>}</pre><p>Thank you for reading this article, if you enjoyed it and would like to support my work feel free to try out Life Planner app <a href="https://thelifeplanner.co/download">thelifeplanner.co/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9d5da01c9fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javarevisited/jakarta-servlets-6-1-on-httpservlet-d9d5da01c9fd">Jakarta Servlets 6.1 : On HttpServlet</a> was originally published in <a href="https://medium.com/javarevisited">Javarevisited</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jakarta Servlet 6.1: On The Servlet Interface]]></title>
            <link>https://samuelowino.medium.com/jakarta-servlet-6-1-on-the-servlet-interface-f58d6801ac1a?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f58d6801ac1a</guid>
            <category><![CDATA[java-servlet]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[jakarta]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Wed, 20 May 2026 10:52:10 GMT</pubDate>
            <atom:updated>2026-05-20T11:09:09.152Z</atom:updated>
            <content:encoded><![CDATA[<p>The jakarta servlet interface is a regular java interface defined by the Jakarta servlet specification.</p><p>The servlet interface determines classes that qualify as Jakarta EE servlets and whose implementations can be used to handle http requests and generate http responses for clients.</p><p>The servlet interface forms the central abstraction within the Jakarta EE servlets API.</p><p>Servlets are created by either directly implementing this interface or extending classes that implement the interface.</p><pre><br>package jakarta.servlet;<br><br>public interface Servlet {<br><br>}</pre><p>Classes that implement this interface must provide implementations of the init service() and destroy() functions including all other abstract functions declared in the servlet interface.</p><p>Within Jakarta EE’s servlet API, there are two popular implementations of the servlet interface that developers regularly use: GenericServlet and HttpServlet .</p><p>GenericServlet implements the Servlet interface directly while HttpServlet extends GenericServlet which intern implements the Servlet interface.</p><pre>package jakarta.servlet;<br><br>public abstract class GenericServlet implements Servlet {<br>   @Override<br>   public abstract void service(ServletRequest req, ServletResponse res);<br>}</pre><p>Notice that GenericServlet leaves the implementation of the service() method to the class that extends GenericServlet .</p><pre>public abstract class HttpServlet extends GenericServlet {<br><br>}</pre><p>Notice that HttpServlet extends the GenericServlet.</p><p>In most cases, developers will extend HttpServlet to implement their own custom servlets that are capable of handling http requests.</p><pre>public class MyHelloServlet extends HttpServlet {<br><br>}</pre><p><strong>Request Handling</strong></p><p>The main contract between a servlet such as MyHelloServlet and a servlet container such as Tomcat is the service() method.</p><p>The service() method is tasked with handling <strong>all request.</strong></p><p><strong>Service() </strong>method is called for each requests that the servlet container routes to the servlet.</p><p>Every time a user makes a request to a web server, the servlet container (e.g. Tomcat or Jetty) invokes the service() method in the servlet that is capable of handling that request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jnrc-QJlQ7z60cU420Ffow.png" /><figcaption>Flow diagram for request routing from client to a servlet</figcaption></figure><p>As shown on the diagram:</p><p>Whenever a client makes a request to a web server, the request reaches the servlet container (in this case Tomcat).</p><p>The servlet container will find the servlet that can handle this request and route the request to that servlet by invoking its service() method.</p><p>The service() will handle processing of the request by directing the processing to the respective servlet function such as doGet and a response is then generated.</p><p>The response is sent back to the servlet container, which will send it to the client usually via an intermediary web server such as (Nginx or Apache).</p><p>Thank you for reading this article on the servlet interface.</p><p>If you enjoyed reading and would like to support my work, don’t hesitate to check out <a href="https://thelifeplanner.co/download">thelifeplanner.co/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f58d6801ac1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jakarta Servlet 6.1: On Servlet Basics]]></title>
            <link>https://samuelowino.medium.com/jakarta-servlet-6-1-on-servlet-basics-61e2f636ae02?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e2f636ae02</guid>
            <category><![CDATA[jakarta]]></category>
            <category><![CDATA[servlet]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Wed, 13 May 2026 12:18:15 GMT</pubDate>
            <atom:updated>2026-05-13T13:02:35.211Z</atom:updated>
            <content:encoded><![CDATA[<p>Java is most commonly used to build enterprise software systems. Enterprise systems fall in the class of organisation wide systems that serve multiple categories of clients, such as browser clients, mobile clients, and even desktop clients.</p><p>This is possible because enterprise Java particularly Jakarta EE (previously Java EE) provides a set of specifications that comprise web components, that are used to build server side (backend) applications that serves these web clients.</p><p>Therefore, it becomes possible to have a Java enabled server side system that serves many clients.</p><blockquote><a href="https://samuelowino.medium.com/jakarta-servlet-6-1-on-servlet-basics-61e2f636ae02?source=friends_link&amp;sk=8e36bd4a95186b3ddcf933c5a8ff52c6">If you are not a medium member, you can read this article here for free</a></blockquote><p>Such distributed systems are made possible via a wide range of technologies, such as web servers, internet protocols such as HTTP, and server side technologies such as Jakarta EE.</p><p>Jakarta EE provides plenty of components that enable the development of server side web applications, but key among these is Jakarta servlets.</p><p>A Jakarta servlet is a Jakarta EE component managed by the application container and that has the capability to generate dynamic content.</p><p>In essence, servlets are java classes that are translated into platform neutral byte code and that can be dynamically loaded and run by a Jakarta EE compliant web server.</p><h3><strong>Servlet Containers</strong></h3><p>Servlet containers (sometimes called servlet engines) are extensions of web servers that are able to provide servlet functionality.</p><p>Servlet functionality here referring to the ability to receives requests from clients (such as browsers), to process these requests and return a response after processing.</p><p>Servlet containers implement a request/response paradigm that servlets use to interact with web clients.</p><p>As of Jakarta servlets version 6.1, servlet containers are required to support HTTP/1.1 and HTTP/2.</p><p>While supporting HTTP/2, servlet containers are required to support <strong>h2 </strong>and <strong>h2c.</strong></p><p><strong>h2 </strong>refers to HTTP/2 that runs over HTTPS (which means all traffic is routed via TLS/SSL security).</p><p><strong>h2c </strong>refers to HTTP/2 that runs over cleartext traffic, i.e not using TLS/SSL traffic encryption.</p><p>Jakarta servlet specification (v<strong>6.1</strong>) requires servlet containers such as Tomcat to support these two modes for HTTP/2 traffic.</p><p>For this support to be possible, servlet containers need to implement <strong>ALPN</strong> (<strong>Application Layer Protocol Negotiation</strong>), which enables the server and client to determine the HTTP protocol version before any data is exchanged between the client and the server.</p><blockquote>If you want to learn more about HTTP, I have written a few articles on it that are available to you.</blockquote><blockquote><a href="https://samuelowino.medium.com/rfc-2616-on-http-messages-e59aaa618260">RFC 2616: On HTTP Messages</a></blockquote><blockquote><a href="https://samuelowino.medium.com/on-http-connection-8547f8b8cd2a">RFC 2616: On HTTP Connection</a></blockquote><blockquote><a href="https://samuelowino.medium.com/rfc-2616-on-http-1-1-fc59506844a3">RFC 2616: On HTTP/1.1</a></blockquote><h3><strong>Servlet HTTP Request Processing</strong></h3><p>A servlet is able to process a request from a client in about 5 steps:</p><ol><li>Step 1: Client connects to the web server and makes a HTTP request. The HTTP request is expected to contain all the necessary information required to process the request such as the HTTP method, headers, affected resource URI and request body if needed.</li><li>Step 2: This makes the handoff stage where the web server (for example Apache or Nginx) receives the HTTP request and hands over processing to the servlet container (for example Tomcat).</li><li>Step 3: This stage happens inside the servlet container. The servlet container determines which servlet (Java class) to invoke to process the request. The servlet container invokes the correct servlet and passes on two objects that it received from the web server, the <strong>request object </strong>and <strong>response object. </strong>The request object maps to the http request while the response object maps to what will become the http response.</li><li>Step 4: The correct servlet performs whatever logic it needs to so as to process the request, after which, the servlet generates the data required for the http response.</li><li>Step 5: The servlet sends the final response object back to the servlet container, which hands off the response object to the web server which in-turn will deliver the http response back to the client. The servlet container ensures that the http response is properly flushed and returns control back to the host web server.</li></ol><p>Thank you for reading this article on Jakarta Servlets.</p><p>If you like what you read and would like to support my work, feel free to checkout <a href="https://thelifeplanner.co/download">thelifeplanner.co/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e2f636ae02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFC 2616: On HTTP Messages]]></title>
            <link>https://samuelowino.medium.com/rfc-2616-on-http-messages-e59aaa618260?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e59aaa618260</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[http-message]]></category>
            <category><![CDATA[http-response-status-code]]></category>
            <category><![CDATA[http-response]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Mon, 11 May 2026 11:10:31 GMT</pubDate>
            <atom:updated>2026-05-13T13:07:50.538Z</atom:updated>
            <content:encoded><![CDATA[<p>HTTP stands for Hypertext transfer protocol. It is an application layer network transfer protocol created in 1990 to serve the world wide web.</p><p>At its foundation, HTTP enables two nodes (client and server) on the internet to connect to each other and exchange data.</p><p>HTTP defines the concept of a request and a response.</p><blockquote>If you are not a medium member you can read this article here for free: <a href="https://samuelowino.medium.com/rfc-2616-on-http-messages-e59aaa618260?source=friends_link&amp;sk=d58a1b0ed1c8e46f59d476c1ad1b5fc6">https://samuelowino.medium.com/rfc-2616-on-http-messages-e59aaa618260?source=friends_link&amp;sk=d58a1b0ed1c8e46f59d476c1ad1b5fc6</a></blockquote><p>A request in HTTP is a message sent from the client to the server requesting access to a resource. A resource can be in the form of data (patient record, financial markets trade or even a simple document).</p><p>Once the server receives the request, it will send a response back to the client, containing the data the client requested or information pertaining to the result of attempts to extract the information in the form of status codes.</p><p>Both a HTTP request and HTTP response utilize the concept of a HTTP message. This helps standardise the format of communication between the client and the server.</p><p>HTTP messages are standardised and as such, use a generic BNF/Augmented BNF format to define the components stored in these messages.</p><p>All HTTP messages contains the following standard components:</p><ol><li>Start line (request line or status line)</li><li>Zero or more headers</li><li>Empty line (CRLF)</li><li>A message body</li></ol><p><strong>HTTP Message Start Line</strong></p><p>The http message start line can vary depending on the type of http message, either a request message or response message. In the case of a http request the start line will contain the following components:</p><ol><li>HTTP Method</li><li>Resource URI</li><li>HTTP Version</li></ol><p>These components will all appear in one line which ends with a CRLF <strong>(Carriage Return Line Feed).</strong></p><blockquote>A carriage return line feed is combination of two ASCII characters (\r and \n). CRLF is used to denote end of line for each statement in the HTTP message as well as to denote empty spaces. CR is ASCII 13 or <strong>0x0D</strong> and LF is ASCII 10 or <strong>0x0A</strong></blockquote><p>Here is the HTTP Request Start Line Format</p><pre>&lt;HTTP Method&gt; &lt;Request URI&gt; &lt;HTTP Version&gt; </pre><p>The HTTP method can be any of the available HTTP methods such as <strong>GET, POST, PUT, DELETE</strong> etc.</p><p>The request URI is a string that points to the resource the client is trying to access on the server. For example, <em>/index.html</em> or <em>/user/2</em>.</p><p>The HTTP version denotes the client’s preferred HTTP version and can be one of; <strong>HTTP/1.0, HTTP/1.1, HTTP/2 or HTTP/3</strong>.</p><p>Here is an example of a request start line</p><pre>GET /index.html HTTP/1.1</pre><p>In the case of a HTTP response, the start line will contain a <strong>HTTP status line</strong>. The status line contains the status of the response which tells the client, whether or not the request was processed successfully.</p><p>In the case where the server was either unable to or unwilling to process the request, the server will respond with a 3 digit status code and a reason phrase telling the client why the request was or was not processed.</p><p>Therefore, the HTTP Status Line contains the following components:</p><ol><li>HTTP Version</li><li>Status Code</li><li>Reason Phrase</li></ol><p>The HTTP version is similar to the request (start) line HTTP version definition.</p><p>The status code is a 3 digit code, such as 200, 301,500 etc, that falls into the following categorization:</p><ol><li>1xx — Informational (wait for final response)</li><li>2xx — Success</li><li>3xx — Redirection</li><li>4xx — Client error such as bad request</li><li>5xx — Server error; server failed to process request</li></ol><p>The status code can tell the client that a resource was not found, authentication or authorisation failed, the server experienced an error while processing the request, the client is redirected elesewhere among other types of results.</p><p>The status line also contains a reason phrase that matches with the status code. The reason line will for example contain, <strong>OK</strong> for status code <strong>200</strong>, <strong>NOT FOUND</strong> for status code <strong>404</strong>, <strong>INTERNAL SERVER ERROR</strong> for status code <strong>500</strong> etc.</p><p>With this information, the client will be able to understand exactly what happened with their request once it reached the server.</p><pre>HTTP/1.1 200 OK \r\n</pre><p><strong>HTTP Headers</strong></p><p>Http headers are the next component of HTTP request messages, after the start line. Http headers enable clients to provide additional crucial details about their request to the server. Http headers are defined using the following format:</p><pre>&lt;Header-Name&gt;:&lt;Header-Value&gt;</pre><p>The HTTP request message can contain zero or more headers.</p><pre>HOST: thelifeplanner.co<br>Content-Type: application/json<br>Content-Length: 37<br>User-Agent: Mozilla/4.0</pre><p>There are very many types of HTTP headers and they serve a variety of purposes.</p><p>In our example above, the Host http header tells the server the name of the server it is attempting to access (thelifeplanner.co), the <strong>Content-Type </strong>header tells the server that the client’s message body will likely contain JSON data (application/json) and the <strong>User-Agent</strong> tells the server the type of end user application from which this request originated (Mozilla/4.0).</p><p><strong>HTTP Message Empty Line (CRLF)</strong></p><p>The next component (after headers) in a HTTP message is an empty line that contains a CRLF, denoting the end of HTTP headers and beginning of message body (if the http message contains a body).</p><p>Here is the format:</p><pre>...last header line...\r\n<br>\r\n &lt;-- empty line (contains only crlf)<br>message body (optional)</pre><p>Here is an example of the empty line after headers definition:</p><pre>GET /api/user/2 HTTP/1.1 \r\n<br>HOST: thelifeplanner.co \r\n<br>Content-Type: application/json \r\n<br>Content-Length: 37 \r\n<br>User-Agent: Mozilla/4.0 \r\n<br>\r\n<br>{<br>  &quot;id&quot;: 12345,<br>  &quot;firstName&quot;: &quot;John&quot;,<br>  &quot;lastName&quot;: &quot;Doe&quot;,<br>  &quot;email&quot;: &quot;john.doe@example.com&quot;,<br>  &quot;phone&quot;: &quot;+1-555-123-4567&quot;,<br>  &quot;age&quot;: 30,<br>  &quot;isActive&quot;: true<br>}</pre><p><strong>HTTP Message Body</strong></p><p>The final component of a HTTP message is the message body.</p><p>This part of the HTTP message contains data that is sent alongside the HTTP request or HTTP response.</p><p>The server discovers the HTTP message body by looking for content after the CRLF that comes after the headers list. The message body can be in many different formats such as, <strong>HTML</strong>, <strong>JSON</strong>, <strong>XML</strong> or even <strong>plain text</strong>.</p><p>The client is able to inform the server about the format of the message body using the <strong>Content-Type</strong> HTTP header.</p><pre>GET /api/user/2 HTTP/1.1 \r\n<br>HOST: thelifeplanner.co \r\n<br>Content-Type: application/json \r\n<br>Content-Length: 37 \r\n<br>User-Agent: Mozilla/4.0 \r\n<br>\r\n<br>{<br>  &quot;id&quot;: 12345,<br>  &quot;firstName&quot;: &quot;John&quot;,<br>  &quot;lastName&quot;: &quot;Doe&quot;,<br>  &quot;email&quot;: &quot;john.doe@example.com&quot;,<br>  &quot;phone&quot;: &quot;+1-555-123-4567&quot;,<br>  &quot;age&quot;: 30,<br>  &quot;isActive&quot;: true<br>}</pre><p>Thank you for reading this not-so-short essay on HTTP messages.</p><p>If you liked what you read and would like to support my work, don’t hesitate to check out <a href="https://thelifeplanner.co/download">thelifeplanner/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e59aaa618260" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFC 2616: On HTTP Connection]]></title>
            <link>https://samuelowino.medium.com/on-http-connection-8547f8b8cd2a?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8547f8b8cd2a</guid>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Fri, 08 May 2026 10:20:06 GMT</pubDate>
            <atom:updated>2026-05-11T10:02:17.363Z</atom:updated>
            <content:encoded><![CDATA[<p>HTTP (Hypertext transfer protocol) is an internet protocol that facilitate internet communication on the World Wide Web. HTTP has been in use since 1990 as HTTP/0.9, but it has evolved over the years, from HTTP/0.9 to HTTP/1.0, HTTP/1.1 and recently HTTP/2 and HTTP/3.</p><blockquote><a href="https://samuelowino.medium.com/on-http-connection-8547f8b8cd2a?sk=d3a95f0abbc60b1a369bbaaee8b13699">If you are not a medium member you can read this article here</a></blockquote><p>Each new version of HTTP has brought several degrees of improvement to how the protocol handles connecting multiple nodes on the world wide web and how to manage data interchange, as well as security concerns that have emerged and evolved since its introduction in 1990.</p><p>The main responsibility of HTTP as a protocol, is the establishment of a virtual communication pipeline between a client and a server. The client can be a user agent such as a browser, while the server is usually a separate computer on the other side of the world. Most HTTP requests are used to serve HTML web pages but some servers provide APIs (Application Programming Interfaces) that allow other computers on the internet to communicate with these servers programatically over an interface.</p><p>Wheather the server is simply serving HTML documents for a website or exposing a private or public API, the connection and handling of the traffic is done over HTTP.</p><p>The establishment of a HTTP connection is often performed in 6 steps. These steps can differ depending on the HTTP version, the nature of the client request or the structure of the server. For example, some servers will often route incoming requests through a proxy or gateway.</p><p><strong>Step 1: DNS Lookup</strong></p><p>DNS stands for Domain Name System.</p><p>When a client application, for example a browser wants to visit a website on the internet, the user of the browser will type in the domain name for example <a href="http://www.pets.com./">www.thelifeplanner.co</a>.</p><p>The computers on the internet are identified by machine ids called IP addresses, for example 127.0.0.4, and not domain names. This means the name entered by the user must be translated to the IP address of the server that stores the HTML documents for <a href="http://www.thelifeplanner.co./">www.thelifeplanner.co.</a></p><p>The DNS is solely responsible for this initial phase of establishing a HTTP connection.</p><p>As mentioned, the DNS will map the domain name to an actual IP address and send the GET/ message to the specific machine on the internet that is responsible for serving the HTML documents.</p><p>There are a few things that happen in this phase (DNS Lookup) that are beyond the scope of this article, stay tuned for a future articles on the topic.</p><p><strong>Step 2: TCP Handshake</strong></p><p>TCP stands for Transmission Control Protocol.</p><p>TCP is used to manage the handshake process between a client machine and the server at the transmission layer of the network stack. TCP is able to achieve this by completing the following key steps.</p><p>Firstly, TCP receives the clients <strong>SYN</strong> (Synchronisation) packet. This packet contains 32-bit digits/sequence of numbers, that contains details about the client and the nature and type of request (source, destination, port numbers, and flags).</p><p>Secondly, TCP sends a <strong>SYN-ACK</strong> (Acknowledgement) packet to the client, confirming that the connection request was received.</p><p>Thirdly and lastly, the client sends a similar <strong>ACK</strong> (Acknowledgement) packet back to the server.</p><p><strong>Step 3 (HTTPS Only): TLS/SSL Handshake</strong></p><p>If the client sends a secure connection request (<strong>HTTPS</strong>), the http protocol will handle negotiations for which encryption protocol/algorithm to use with the client. The http protocol will also handle the exchange of security <strong>certificates</strong> with the client and the verification of these certificates.</p><p>Once the <strong>TLS/SSL</strong> handshake step completes successfully, the request processing moves to the next step.</p><p><strong>Step 4: Client HTTP Request Processing</strong></p><p>The client is now able to send the actual HTTP request with the relevant data and http modifier, including any headers. For example, GET/index.html.</p><p><strong>Step 5: Server Request Processing and Response</strong></p><p>The server attempts to process the request and generates a response.</p><p>The response may contain status codes such as <strong>200 OK, 400 BAD_REQUEST or 500 INTERNAL_SERVER_ERROR</strong>, depending on how the request processing actual went down.</p><p>The http response will often also contain data that is sent back to the client.</p><p><strong>Step 6: Closing of HTTP Connection/Reuse of Connection</strong></p><p>The final step of processing a HTTP request depends on the HTTP version being used. Prior to HTTP/1.1, the HTTP connection would be closed at this stage and the client would have to begin this process afresh for subsequent HTTP requests.</p><p>As of HTTP/1.1, the existing HTTP connection can be reused for subsequent requests from the same client to the same server, referred to as <strong>persistent connections</strong>.</p><p>Thank you for reading this article on HTTP Connections.</p><p>If you would like to support my work, feel free to checkout <a href="https://thelifeplanner.co/download">thelifeplanner.co/download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8547f8b8cd2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFC 2616: On HTTP/1.1]]></title>
            <link>https://samuelowino.medium.com/rfc-2616-on-http-1-1-fc59506844a3?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc59506844a3</guid>
            <category><![CDATA[essay]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Mon, 04 May 2026 16:21:36 GMT</pubDate>
            <atom:updated>2026-05-13T13:12:28.501Z</atom:updated>
            <content:encoded><![CDATA[<p>HTTP which stands for Hypertext Transfer Protocol is an internet protocol first introduced in 1990 for use on the world wide web. HTTP/0.9 was designed to standardize the transfer of raw data on the internet. As its usage increased, some of its glaring weaknesses became obvious which led to the introduction of HTTP/1.0.</p><blockquote>If you are not a medium member, you can read this article here for free: <a href="https://samuelowino.medium.com/rfc-2616-on-http-1-1-fc59506844a3?source=friends_link&amp;sk=2281d98db95a2df345249f4a3ed0a12a">https://samuelowino.medium.com/rfc-2616-on-http-1-1-fc59506844a3?source=friends_link&amp;sk=2281d98db95a2df345249f4a3ed0a12a</a></blockquote><p>HTTP/1.0 introduced support for data formats that were more like MIME (Multipurpose Internet Mail Extensions). This meant that finally HTTP could support transfer of other media formats such as audio and video. HTTP/1.0 also made it possible to include metadata/meta-information alongside the main data being transferred. It also, added the ability to define modifiers (headers and methods) on the already existing request/response semantics.</p><p>HTTP/1.0 however, failed to address a number of challenges including; the effects of proxies and gateways, caching, persistent connections and virtual hosts. This created room for the development and later formalization of the HTTP/1.1 standard.</p><p>HTTP/1.1 addressed most of these challenges as well as formalizing the use of resource references, for example, the use of resource identifiers (URIs), resource locators (URLs) and resource names (URNs). These standards ensured that HTTP requests clearly stipulated the resource to which the HTTP methods are to be applied.</p><p>HTTP has manged to serve as the backbone of information interchange in the internet since it’s introduction in 1990. It has achieved this by providing an open ended set of headers and methods that clearly indicate the purpose and nature of HTTP requests.</p><p>Another key strength of HTTP (as of HTTP/1.0) has been the use of MIME-like messages which make it possible to share a variety of data formats not just ASCII text, as it was with HTTP/0.9</p><p>In today’s world, HTTP is used to manage communcation on the internet between user agents (such as browsers), proxies and gateways to other systems on the internet, as well as with systems that rely on other complemenary protocols such as SMTP, FTP, Gopher, NNT and WAIS.</p><p>Thank you for reading this brief essay on <strong>RFC 2616/HTTP 1.1</strong>.</p><p>If you would like to support my work feel free to visit <a href="https://thelifeplanner.co/download">thelifeplanner.co.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc59506844a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On REST]]></title>
            <link>https://samuelowino.medium.com/on-rest-5cac5145e81c?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cac5145e81c</guid>
            <category><![CDATA[essay]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[restful-api]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Wed, 29 Apr 2026 08:26:52 GMT</pubDate>
            <atom:updated>2026-05-13T13:14:34.212Z</atom:updated>
            <content:encoded><![CDATA[<p>Representational state transfer is an architecture style invented by Roy Fielding in his PhD dissertation “Architectural Styles and the design of Network Based Software Architectures” in the year 2000. REST was created to define how network based communication can be implemented over internet protocols such as HTTP.</p><p>REST was designed around several core principles such as; Client-Server, Stateless communication, Cacheable data interchange, Layered architectural design, and a Uniform Interface (URIs).</p><blockquote><a href="https://samuelowino.medium.com/on-rest-5cac5145e81c?source=friends_link&amp;sk=81076d3ec2f78d026831fa92fda33fb4">If you are not a medium member, you can read this article for free on via this link</a></blockquote><p>Clients and servers are the foundational components in a RESTful architecture. A client is a node in the network that requests access to resources (mainly data but sometimes computation) from a server. The server is the node in the network that computes the data requested by the client and serves this data in the form of plain-human-readable text.</p><p>Stateless priciples in RESTful architectures refers to the encapsulated nature of the client and server. For example, when the client is “at rest”, the server is free and thus computation is not consumed on the server side node.</p><p>A layered architecture ensures that the client is not coupled with the server. Communication is performed on a clear interface that does not expose the servers internal representation of data or computation. This means the client does not need to have knowledge of the servers internal implementation and it’s internal data representation, for them to interact.</p><p>The interface that facilitates the interaction between the client and the server is a URI (Uniform Resource Identifier) interface. A URI can be represented as simple text such as (www.pet.com/pets/{petId}). Such representations enable the client to request data from the server in simple language that is not dependent on the servers internal mechanisms.</p><p>Due to it’s layered design, RESTful architecture facilitates cacheable data interchange by ensuring the client is not aware of the actual data source on the server. For example, when a client application goes to <a href="http://www.pet.com/pets/3,">www.pet.com/pets/3,</a> the server can choose to query a persistent source of the pets database or the server can choose to use a pre-existing cache of this data. The client does not have a clear way of knowing how the data was derived, just that the server was able to respond with the correct data in clear text representation (text/json/html/xml).</p><p>HATEOAS (Hypermedia as the engine of application state), is another very important aspect of RESTful architecture. This principles ensures that server side nodes on the network behave like webpages. When you visit a web page, you are not required to already know about all the other internal pages or linked pages that exist on the website. The homepage will provide you links that point to other related web pages. HATEOS in RESTful architecture prescribes that, when a client requests for a resource via a URI, the response will contain URIs to other related resources. This ensures that the client is not hardcoded with all available resource URIs.</p><p>Thank you for reading this short essay on RESTful architecture. If you would like to support my work don’t hesitate to visit <a href="https://thelifeplanner.co/">thelifeplanner.co</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cac5145e81c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On JPA]]></title>
            <link>https://medium.com/spring-boot/on-jpa-d1743b776ea9?source=rss-a431223b6be9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1743b776ea9</guid>
            <category><![CDATA[hibernate]]></category>
            <category><![CDATA[jpa]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[essay]]></category>
            <dc:creator><![CDATA[Samuel Owino]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 07:27:16 GMT</pubDate>
            <atom:updated>2026-04-28T07:27:16.295Z</atom:updated>
            <content:encoded><![CDATA[<p>JPA (Java Persistence API) now renamed to Jakarta Persistence API is one of many Java specifications that form the web standards specification set in the Java ecosystem. These specification sets are developed and maintained by the Eclipse foundation after they were handed over from Oracle, which maintained them under the Java EE (Java Enterprise Edition) project.</p><p>JPA aims to design and standardized how Java enterprise applications perform data persistence independently of the underlying database management system. JPA can also be considered Java’s attempt at standardizing ORM (Object Relational Mapping) implementations for the Java developer ecosystem.</p><p>Object relational mapping empowers Java developers to write persistence layers without the worry of coupling directly with the underlying database management system such as MySQL, Oracle, Postgres or SQLite. A java developer is able to define entities as regular Java classes and the JPA specification defines how those classes will be mapped to the underlying database managemt system. This provides a great deal of convenience to developers and helps developers ship software projects faster and more efficiently.</p><p>JPA is just a specification in the form of a pdf document. This means for Java developers to actually take advantage of the standard they require an implementation of the standard, usually in the form of a library. There are several implementations of the JPA specification, most prominent of these is Hibernate. Hibernate is the most popular implementation of the Jakarta Persistence API specification.</p><p>Considering the vast nature of the Java developers ecosystem, it is only natural for the community to create additional layers of convenience, thats how we get “wrappers” around Hibernate’s implementation of the JPA specifications such as Spring Data JPA, which wraps around Hibernate making its usage much easier and more convenient, for example, by providing CRUD interfaces that have preset implementations that the developer can plug in to their project and immediately execute with minimal to zero additional code.</p><p>Thanks a lot for reading this short essay.</p><p>If you would like to support my work, feel free to checkout <a href="http://thelifeplanner.co/">thelifeplanner.co</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1743b776ea9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spring-boot/on-jpa-d1743b776ea9">On JPA</a> was originally published in <a href="https://medium.com/spring-boot">JavaToDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>