<?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 Shaheen hyder k on Medium]]></title>
        <description><![CDATA[Stories by Shaheen hyder k on Medium]]></description>
        <link>https://medium.com/@shaheenhyderk?source=rss-98e8f0ffdfee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QgpAIusKfnI5gdOLWFgODQ.jpeg</url>
            <title>Stories by Shaheen hyder k on Medium</title>
            <link>https://medium.com/@shaheenhyderk?source=rss-98e8f0ffdfee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:16:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shaheenhyderk/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[Create a Spring MVC project in IntelliJ (Part 1)]]></title>
            <link>https://medium.com/@shaheenhyderk/create-a-spring-mvc-project-in-intellij-part-1-331264b5289b?source=rss-98e8f0ffdfee------2</link>
            <guid isPermaLink="false">https://medium.com/p/331264b5289b</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-mvc]]></category>
            <dc:creator><![CDATA[Shaheen hyder k]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 19:40:21 GMT</pubDate>
            <atom:updated>2022-09-26T19:51:30.274Z</atom:updated>
            <content:encoded><![CDATA[<p>Hai programmer,</p><p>Let&#39;s learn to create a java spring project in IntelliJ Ultimate with MySQL connection and database pooling. First, let&#39;s know what all these concepts are.</p><p>So let&#39;s see what Spring MVC is, <a href="https://www.javatpoint.com/spring-mvc-tutorial">click here</a>.</p><p>Now, let’s start the coding, Here I am using ubuntu 20.04, java 8, and IntelliJ Ultimate 2020.2.4. First, create a maven project with the web app archetype.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6yW5pSct7HOJWQgRkAsbw.png" /></figure><p>Then, name the project and finish it. Now you will get a project like the screenshot below. Here ‘shophere’ is my project name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-jWwRFrWoKLtwqUBmURxEQ.png" /><figcaption>View of initialized project</figcaption></figure><p>Now we got a base structure and now let&#39;s add maven dependency of Spring MVC. Add the following code to your dependency in pom.xml. Pom file is where we manage libraries for this project.</p><pre>&lt;dependency&gt;<br> &lt;groupId&gt;org.springframework&lt;/groupId&gt;<br> &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;<br> &lt;version&gt;5.3.23&lt;/version&gt;<br>&lt;/dependency&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZVuNI-mO5yYXDxF6lvCDrA.png" /></figure><p>Now reload the maven of the current project by clicking any of the buttons marked below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKC18UfxGQZGKshW7_e8sQ.png" /><figcaption>Button for syncing maven dependencies</figcaption></figure><p>Now let&#39;s run this project. For that download the tomcat server. Here I use tomcat 8. Download it from <a href="https://tomcat.apache.org/download-80.cgi">https://tomcat.apache.org/download-80.cgi</a>, extract the zip file, and copy it to our project as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkBibWNvrxhOsCAqc4qQMg.png" /></figure><p>Now click on Add configuration on the top right. And click the + button in the configuration tab as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnYIBNUZyFGqPpnpezQ3gg.png" /></figure><p>From the dropdown select tomcat server &gt; local as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qi5P2jeCyaJHpNvTUMCV4A.png" /></figure><p>Now give a name and click on configure and add the path of your extracted folder as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1MpT7In_3tRuin9CbYuViA.png" /></figure><p>Now move to the deployment tab and press the + button and click on Artifact as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ps46CdK8a4fm-j8ixYxozg.png" /></figure><p>Now select war and war exploded and hit ok.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7WQFyteO6oTKQc0pJyiWw.png" /></figure><p>Now all the configurations are done so hit ok to the configuration menu. Now select tomcat 8 and hit on the run as shown below.</p><p>NOTE:- After running the project you can see an extra folder named target. Don’t bother with that. It is just the compiled code of our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ox-vGNc3WKhh5lolns-nmQ.png" /></figure><p>Now you may hit an error with the message permission disabled. If so it is because in tomcat/bin catalina.sh don&#39;t have permission to execute. So let&#39;s permit to execute.</p><pre>chmod a+x {path-to-tomcat}/bin/catalina.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*neDD0-Wr9wqYM5pDst_Vdg.png" /></figure><p>Now hit run.. Wow we got our first page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mfG6OsDbT_eOQVqlirjQzg.png" /></figure><p>But now when we look at our URL it is ‘localhost:8080/shophere_war’. But we don&#39;t want that extra /shophere_war. We just want our page to be loaded in the root. So let&#39;s do something for removing that. For that click on edit configuration of our as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-wC_06lKT-VXmN3M7lwIg.png" /></figure><p>Now select our current server and select the deployment tab and change the application context to empty as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOCnZNSveAMocTBDbR7t-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yeBKItejm6mnZozbqZB6-A.png" /></figure><p>Now restart our server and see here got it perfect now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VogvVvR7MGT2EFEkODLv4Q.png" /></figure><p>Now our hello world is up… Now let&#39;s configure some java classes and all.</p><p>Now add a package named ‘java’ inside main and add another directory as our domain name eg:- by default we use org.example. So it will be like java&gt;org&gt;example. We will add all our java classes to this package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-jxV4k7p_DTpCpaVO0M_Q.png" /></figure><p>Now we will create a controller. For better readability, we will create a directory named controller and place our controller class inside this.</p><p>The controller class is the place where we write our logic, URL mapping, etc.</p><p>Then add @Controller so that spring understands it is a controller class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BifaIdvUcSSY500iJpx75A.png" /></figure><p>Now we will keep the controller as it is and create an HTML page for our product page.</p><p>So first we will delete the default index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWkVuSh24bpoOu2q4Wzc4g.png" /></figure><p>Then create a directory name ‘jsp’ in WEB-INF and create a jsp page named product. Jsp is the place where we will write our HTML content. Just add some random content so that we can verify we are getting the correct page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eineCnwQ-o2eYg1qhcpk0g.png" /></figure><p>Now go back to our controller class and we will create a function for returning our jsp page we will make that function with a URL by using @RequestMapping</p><pre>@RequestMapping(value = &quot;/products&quot;, method = RequestMethod.GET)<br>public String productDisplay(){<br>    return &quot;product&quot;;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMCjUbp7FsFFFhg3KwDFbg.png" /></figure><p>Here /products is our endpoint for the product page and it is a Get method. In the return statement, we will give the name of our jsp page which should be rendered.</p><p>Now just run our project and let us see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xPecApE7YAxXCDugsWaHQ.png" /></figure><p>Oops, we are not getting our product page even when we navigate to /products. Let’s see what the problem is. We have to do some more configuration to make work this.</p><p>Just replace the web.xml with the following code.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</pre><pre>&lt;web-app xmlns=&quot;<a href="http://xmlns.jcp.org/xml/ns/javaee">http://xmlns.jcp.org/xml/ns/javaee</a>&quot;<br>         xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>         xsi:schemaLocation=&quot;<a href="http://xmlns.jcp.org/xml/ns/javaee">http://xmlns.jcp.org/xml/ns/javaee</a><br>        <a href="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd</a>&quot;<br>         version=&quot;3.1&quot;&gt;<br>    &lt;servlet&gt;<br>        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;<br>        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;<br>        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br>    &lt;/servlet&gt;<br>    &lt;servlet-mapping&gt;<br>        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;<br>        &lt;url-pattern&gt;/&lt;/url-pattern&gt;<br>    &lt;/servlet-mapping&gt;<br>    &lt;context-param&gt;<br>        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;<br>        &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;<br>    &lt;/context-param&gt;<br>    &lt;listener&gt;<br>        &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;<br>    &lt;/listener&gt;<br>&lt;/web-app&gt;</pre><p>Web.xml is the entry point of our project. So in web.xml now we are redirecting all other requests to another XML file name dispatcher-servlet.xml where we will write our configurations.</p><p>So now create a file dispatcher-servlet.xml with the following code.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</pre><pre>&lt;beans xmlns=&quot;<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>&quot;<br>       xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>       xmlns:context=&quot;<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a>&quot;<br>       xsi:schemaLocation=&quot;<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans.xsd">http://www.springframework.org/schema/beans/spring-beans.xsd</a> <a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a> <a href="http://www.springframework.org/schema/context/spring-context.xsd">http://www.springframework.org/schema/context/spring-context.xsd</a>&quot;&gt;</pre><pre>&lt;context:component-scan base-package=&quot;org.example.controller&quot;/&gt;</pre><pre>&lt;bean class=&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;&gt;<br>        &lt;property name=&quot;prefix&quot; value=&quot;/WEB-INF/jsp/&quot;/&gt;<br>        &lt;property name=&quot;suffix&quot; value=&quot;.jsp&quot;/&gt;<br>    &lt;/bean&gt;</pre><pre>&lt;/beans&gt;</pre><p>So now what is written in the dispatcher servlet Here <em>context:component-scan </em>is used to tell spring that these packages are part of our projects. If we have any other packages include that also.</p><p>The bean defined in our dispatcher servlet is for configuring our jsp pages.</p><p>Now, let&#39;s start our server and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SO1z672ctTkJ7RltgRUpkA.png" /></figure><p>Oops, it&#39;s again showing an error. The reason is now it is the root URL (/). And we have configured only /products endpoint. So let&#39;s take that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsPLyX5bh4IR3e9hV3ssRQ.png" /></figure><p>Wow, now we have got it. And now our base structuring is done.</p><p>Now let&#39;s do one more thing. If a user goes to the root URL we will redirect to the product page. For that let us create a new controller named HomeController and add the code below.</p><pre>@Controller<br>public class HomeController {</pre><pre>    @RequestMapping(value = &quot;/&quot;, method = RequestMethod.GET)<br>    public String productDisplay() {<br>        return &quot;redirect:/products&quot;;<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bDlPVfixmHyK1mDSoWr6yg.png" /></figure><p>Yes, now we can see even when we take the root URL it redirects to /products and shows our page. So our setup is ok.</p><p>Now let&#39;s try passing data from the controller to jsp (HTML side). So let’s try different approaches to sending data to jsp. Model is an Interface that is used to pass data to jsp. We can add multiple key-value pairs to the model. Let’s try passing data through the Model. Model is an interface from package org.springframework.ui.</p><p>Add Model as an argument to our function as shown below in ProductController.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26XvkzdSLu9QiU2Gm6TEpg.png" /></figure><p>Now we can add our data to the model so that it will be available in jsp. We can add data by model.addAttribute(). It takes 2 arguments first is attribute-name and the second is attribute-value. Add the following code to our function body.</p><pre>model.addAttribute(&quot;name&quot;, &quot;macbook air&quot;);<br>model.addAttribute(&quot;price&quot;, &quot;$999&quot;);<br>model.addAttribute(&quot;color&quot;, &quot;gray&quot;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4MUuuBH49TIPKFx5B7V8cg.png" /></figure><p>Now let&#39;s access these values in our jsp. For accessing values, just use ${attribute-name} in jsp page. So in our case use ${name}, ${price}, ${color} as these are the key names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r34omfsaqAuZfS-lWxNqFg.png" /></figure><p>Now run the server and see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0E9BcpTZpnvVRrQnfT9Fg.png" /></figure><p>Now let&#39;s modify the HTML content and try refreshing the page. See the below screenshots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2H0-65zzsoRR2OLgkgCQA.png" /></figure><p>Now I changed some HTML content and let me try refreshing the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMdl2TSUjvO1sbe_qaipuw.png" /></figure><p>Waaaat!! it hasn&#39;t reflected in the browser. Let&#39;s see why isn&#39;t it updating instantly.</p><p>Whenever we are hitting run from ide they are creating a build of the project to the target folder and that build is used for our server. So let’s see what’s happening here. Here we haven&#39;t clicked run / restart / redeploy / rebuild again after editing the jsp page. So it is using the previous build. So let&#39;s do some auto-configuration for that.</p><p>Click on the edit configuration of our tomcat. And open the Deployments tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbM3UF1DdtRpHTp_PKOyIg.png" /></figure><p>Now remove the war(shophere:war) by clicking ‘-’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2cVACphVDlFgnsdJdMX2g.png" /></figure><p>Now select the war exploded and make the application context empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq-xFTkFsa2aHXPb8FtR3g.png" /></figure><p>After that, it will be as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnnoQ7KfEojmPwrn1ZohRQ.png" /></figure><p>Now go to the server tab and change <em>on frame deactivation</em> to <em>Update classes and resources</em>. So that whenever we change the window it will automatically update classes and resources. Note:- it won&#39;t redeploy/create a new build. It will load only some data like jsp pages, the body of functions, variables, etc. If we are modifying class name, function name or arguments, etc we should redeploy or restart the server.</p><p>Now let&#39;s change <em>on frame deactivation. And hit Ok.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iN-gp7KmvYZEkUhHxWooJQ.png" /></figure><p>Now restart the server. Now if we do any HTML changes we can see that it is changing by just refreshing the browser.</p><p>Now, let&#39;s move to our topic of sending data from controller to jsp. Just look at what we have done. Now instead of adding each attribute to the Model, we will create a class and add data to that and pass the object to the model.</p><p>So let’s create a class name ProductPage. For that we will create a new directory named model in java &gt; org&gt; example.</p><p>Note: all the directories like controller, model, etc. are for making the product structure good. Even if we can write all files in a single directory, it will work. But it will be very much messy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbG4nqUIMZ1dValT41q1jg.png" /></figure><p>Now add the properties to our class and getter and setter also.</p><p>Note: we will add all properties as private, a public get function for retrieving data, and a public set function for setting data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuI5KGGTrUorYrG0bIc3qg.png" /></figure><p>Now add getter and setter functions for all attributes. For that in IntelliJ, there is a shortcut. Place mouse pointer to the corresponding attribute and hit alt + enter you can see a menu click on <em>create getter and setter</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a9QkSpWbJruLXwBZOOECOA.png" /></figure><p>Add the same for all attributes. So it will be just like the following images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZNYLW3qAEzmDYOz3CkAQQ.png" /></figure><p>Now in our ProductController create an object of ProductPage and set the values and add it to the Model.</p><pre>ProductPage productPage = new ProductPage();<br>productPage.setName(&quot;macbook air&quot;);<br>productPage.setPrice(999);<br>productPage.setName(&quot;gray&quot;);</pre><pre>model.addAttribute(&quot;productPage&quot;, productPage);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvPcBSwQ_3SkGTOIgsqYFQ.png" /></figure><p>Now from the jsp page, we can access data with <em>productPage</em>. Let’s do that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bo9cPTNy8ZMWw5trMn5hA.png" /></figure><p>Now redeploy/restart the project and reload our page. You can see the items are loading… So now with this step, we haven&#39;t made any visual changes for the user, but we have structured our code. Let’s do one more tweak.</p><p>Now if we want any data to be sent to jsp we will pass it through our page class.</p><p>Now we will remove the line <em>model.addAttribute(&quot;productPage&quot;, productPage); </em>and add it by using <em>@ModelAttribute()</em>. Let’s see the example.</p><pre>@RequestMapping(value = &quot;/products&quot;, method = RequestMethod.GET)<br>    public String productDisplay(@ModelAttribute(&quot;productPage&quot;)     ProductPage productPage) {</pre><pre>        productPage.setName(&quot;macbook air&quot;);<br>        productPage.setPrice(999);<br>        productPage.setName(&quot;gray&quot;);</pre><pre>        return &quot;product&quot;;<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CN-cycoUoBQl9GTpli6kaQ.png" /></figure><p>This is equivalent to our previous method. @ModelAttribute will create an object of ProductPage and add it to our Model with the key name <em>productPage</em>. The key name is what we have mentioned inside that bracket of @ModelAttribute. So now we can use that particular key name on our jsp page.</p><p>Just try reloading the page and make sure all are working perfectly.</p><p>Now let’s try sending multiple products to our jsp page. So for that instead of using the name, price, etc directly in our ProductPage we will Create a class Product and use that in ProductPage. So that we can pass multiple instances of Product.</p><p>So create a class Product in the model directory, and add a name, price, color to it, and corresponding getters and setters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-M94Ux1lxdUZAu0RdGE2Kw.png" /></figure><p>Now clear our ProductPage and add an attribute of Product and corresponding getter and setter.</p><pre>public class ProductPage {</pre><pre>    private Product product;</pre><pre>    public Product getProduct() {<br>        return product;<br>    }</pre><pre>    public void setProduct(Product product) {<br>        this.product = product;<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTcME9kpV_V41q7JdNopZw.png" /></figure><p>Now modify in our controller also, Create an object of product and set it to our ProductPage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9FDibWS-ltvs2rRWwXJ2A.png" /></figure><p>Now modify our jsp page also. In jsp, we will have access to productPage. From ProductPage we will get Product. From the product, we will get the name, price, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJ7LjlQEDQpSo8u85NdG9A.png" /></figure><p>Now just restart the server and reload our page in the browser and see if all are working fine.</p><p>Now let&#39;s send a list of products. For that first, make our attribute product in our ProductPage to list of products.</p><pre>public class ProductPage {</pre><pre>    private List&lt;Product&gt; products;</pre><pre>    public List&lt;Product&gt; getProducts() {<br>        return products;<br>    }</pre><pre>    public void setProducts(List&lt;Product&gt; products) {<br>        this.products = products;<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVBh_HSpHTDZ8ZoUx9fDgA.png" /></figure><p>Now in our controller make a list of products and pass it to our product page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jR3vw5cItsgJpOmEqT_uOA.png" /></figure><p>Here I have created 3 products and created a list of them. And passed it to our page. We can obviously simplify these codes. But I just kept it in a basic way.</p><p>Now change in our jsp page also. Now we have a list of products in our ProductPage so we want to iterate over the list and print it. We will use JSTL for iterating the list. For that add the following to the top of our jsp page.</p><pre>&lt;%@ taglib uri=&quot;<a href="http://java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core</a>&quot; prefix=&quot;c&quot;%&gt;</pre><p>And add the following code snippet to our HTML part.</p><pre>&lt;c:forEach items=&quot;${productPage.products}&quot; var=&quot;product&quot;&gt;<br>    &lt;h3&gt;Item name: ${product.name}&lt;/h3&gt;<br>    &lt;h5&gt;Item price: ${product.price}&lt;/h5&gt;<br>    &lt;h5&gt;Item color: ${product.color}&lt;/h5&gt;<br>&lt;/c:forEach&gt;</pre><p>Here it will iterate through <em>productPage.products</em> and <em>product </em>will have the value of each product in each iteration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uam5NrXRenLWPNQQZ23Ygg.png" /></figure><p>Here we are using forEach from JSTL, so we should add its dependency to our pom.xml. Add the following and reload maven.</p><pre>&lt;!-- <a href="https://mvnrepository.com/artifact/jstl/jstl">https://mvnrepository.com/artifact/jstl/jstl</a> --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;jstl&lt;/groupId&gt;<br>    &lt;artifactId&gt;jstl&lt;/artifactId&gt;<br>    &lt;version&gt;1.2&lt;/version&gt;<br>&lt;/dependency&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3mczUZ5NtiZ-eItaHBPlPA.png" /></figure><p>Now restart the server and refresh our page in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_4rDHE41C928HX0cFsXfQ.png" /></figure><p>Wow, now we can see all our products.</p><p>So that&#39;s it we will continue with database connection in the next blog. Check it here ……..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=331264b5289b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A spring project with connection pooling, redis cache, message queue, multiserver setup with…]]></title>
            <link>https://medium.com/@shaheenhyderk/a-spring-project-with-connection-pooling-redis-cache-message-queue-multiserver-setup-with-4808de70c289?source=rss-98e8f0ffdfee------2</link>
            <guid isPermaLink="false">https://medium.com/p/4808de70c289</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[spring-mvc]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Shaheen hyder k]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 19:39:38 GMT</pubDate>
            <atom:updated>2022-09-26T19:43:19.544Z</atom:updated>
            <content:encoded><![CDATA[<h3>A spring project with connection pooling, redis cache, message queue, multiserver setup with haproxy as a load balancer, and centralized session.</h3><p>Hai programmer,</p><p>In this blog, we will learn all the above-mentioned topics from multiple blogs. We will cover these just like a series of blogs with continuation. We will start by creating a spring project and move on step by step explaining all the steps and concepts. At last, we will evolve to a highly scalable architecture.</p><ol><li>So first let&#39;s initialize the project and use predefined data without any database. Follow the following as 1st step.<br><a href="https://medium.com/@shaheenhyderk/create-a-spring-mvc-project-in-intellij-part-1-331264b5289b">https://medium.com/@shaheenhyderk/create-a-spring-mvc-project-in-intellij-part-1-331264b5289b</a></li><li>Now we will connect our project with the database and do some crud operations. Follow ……..</li><li>Now we will add some user and login functionalities with session handling. Follow …….</li><li>Now let’s introduce redis and do some data caching. Follow ……</li><li>Now let’s introduce the message queue for doing some tasks asynchronously. Follow ……</li><li>Now let’s do a multiserver setup with haproxy as a load balancer. Follow ……</li><li>Now let&#39;s make a centralized session with redis. Follow …..</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4808de70c289" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>