<?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 Sukhdeep Bangar on Medium]]></title>
        <description><![CDATA[Stories by Sukhdeep Bangar on Medium]]></description>
        <link>https://medium.com/@sukhdeepbangar?source=rss-a6f6a6e75fd8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*e4rxti6x6EdwCDz1go25nw.jpeg</url>
            <title>Stories by Sukhdeep Bangar on Medium</title>
            <link>https://medium.com/@sukhdeepbangar?source=rss-a6f6a6e75fd8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:50:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sukhdeepbangar/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[Journey of an HTTP Request in Spring MVC]]></title>
            <link>https://sukhdeepbangar.medium.com/journey-of-an-http-request-in-spring-mvc-c92a5d99a8ef?source=rss-a6f6a6e75fd8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c92a5d99a8ef</guid>
            <category><![CDATA[restful-api]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-mvc]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Sukhdeep Bangar]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 23:43:43 GMT</pubDate>
            <atom:updated>2023-04-27T23:43:43.900Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial provides an in-depth look at the processing of a Rest API HTTP request in Spring MVC. It highlights the various components the request passes through and explains the purpose of each component in the request processing flow.</p><h3>Introduction</h3><p>Let us start with a quick introduction to the major components involved in handling an HTTP request in Spring MVC:</p><ul><li><em>DispatcherServlet</em>: Central component responsible for orchestrating the request processing flow.</li><li><em>HandlerMapping</em>: Determines the appropriate handler (controller method) to process the incoming request.</li><li><em>HandlerAdapter</em>: Invokes the target handler(controller method) identified by HandlerMapping. It also resolves method arguments and process return values.</li><li><em>HandlerMethodArgumentResolver</em>: Resolves method argument values using annotations like @PathVariable, @RequestParam, and @RequestBody.</li><li><em>HandlerMethodReturnValueHandler</em>: Processes handler method return values and converts the response to the appropriate format (e.g., JSON, XML).</li><li><em>HttpMessageConverter</em>: Converts request and response data between Java objects and serialized representations (e.g., JSON, XML).</li></ul><h3>Processing Flow</h3><p>We will gain a better understanding of how these components interact by examining the following flow diagram.</p><figure><img alt="HTTP Request flow diagram" src="https://cdn-images-1.medium.com/max/881/1*KzjKPDTl6wbw4JQDWTy8rw.png" /><figcaption>HTTP Request Flow</figcaption></figure><ol><li>The first step is to figure out which handler should process the request. The HandlerMapping component is responsible for this. It uses information such as the request URL, HTTP methods, path variables, and HTTP headers to determine the appropriate handler. In Spring MVC, this handler is typically a HandlerMethod, which encapsulates the target controller method and its instance. Once the handler is identified, control is provided to the HandlerAdapter.</li><li>DispatcherServlet calls the preHandle method of HandlerInterceptors before calling the HandlerAdapter. HandlerInterceptor can handle the request itself and stop further processing by returning a boolean value.</li><li>The HandlerAdapter is responsible for invoking the target handler (HandlerMethod), converting request data to Java objects, and converting the response from Java objects to the appropriate representation.</li><li>The HandlerAdapter delegates the task of resolving method argument values to the appropriate HandlerMethodArgumentResolver components, depending on the handler method signature. This may involve parsing path variables, request parameters, or the request body.</li><li>The HandlerMethodArgumentResolver delegates the responsibility of transforming the request to Java objects when using the @RequestBody annotation to the HttpMessageConverter component. This component converts the request data (e.g., JSON, XML) to the corresponding Java objects.</li><li>Before the target method of the controller is invoked, the HandlerMethodArgumentResolver validates the objects if @Valid or @Validated annotations are present. It validates wherever Java Bean Validation annotations or Hibernate validation annotations are present.</li><li>The target method of the controller is invoked.</li><li>The controller now returns a ResponseEntity object or other response types. The HandlerAdapter passes the response to HandlerMethodReturnValueHandler, which processes the return value and converts it to the appropriate representation if necessary.</li><li>The HandlerMethodReturnValueHandler makes use of HttpMessageConverter to convert Java objects to the accepted representations, such as JSON or XML. The response is then sent back to the DispatcherServlet.</li><li>If the controller throws an exception, then the DispatcherServlet invokes the ExceptionHandlerExceptionResolver chain, which, with the help of @ExceptionHandler, @ControllerAdvice, and @ResponseStatus, determines the response to send.</li><li>The DispatcherServlet then calls the postHandle and afterCompletion methods of the HandlerInterceptor after the request is processed.</li></ol><h3>Conclusion</h3><p>In this tutorial, we delved into the processing of HTTP requests in Spring MVC and explored the key components involved. I highly recommend setting breakpoints at each component and walking through an HTTP POST request to gain practical experience. Deeper understanding of these components and their interactions will undoubtedly enhance your skills as a developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c92a5d99a8ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>