<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Express Js &#8211; MaXEster Technologies  | Technical Blog</title>
	<atom:link href="https://www.maxester.com/blog/category/express-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxester.com/blog</link>
	<description>Tutorials, Examples and Implementation code for Developers Help</description>
	<lastBuildDate>Mon, 17 Feb 2025 09:17:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.22</generator>
	<item>
		<title>req and res objects in Express Js</title>
		<link>https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/#respond</comments>
		<pubDate>Wed, 06 Nov 2024 07:21:03 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1330</guid>
		<description><![CDATA[<p>You must have seen the req and res object passed to the callback functions in Express Js. You may have wondered, what are these parameters. req object : req object is passed to any route handler function or in middlewares.&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/">req and res objects in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>You must have seen the req and res object passed to the callback functions in Express Js. You may have wondered, what are these parameters.</p>



<h4>req object :</h4>



<p>req object is passed to any route handler function or in middlewares. It is the object which contains the details sent by the client. </p>



<p>It contains the informations like the headers, url details including pathname, query, port, href, protocol , cookies, any type of form data in string or json format and so on.</p>



<h4>res object :</h4>



<p>res object is passed by the server to the client. It has various fields like headers, the status code, the page data which the user has asked for, details regarding http protocol etc.</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/rr1.png" alt="" class="wp-image-1331"/></figure></div>



<p></p>



<h4>next() :</h4>



<p>Another parameter which is generally passed to a middleware function is &#8220;next&#8221;. next is a reference to the next middleware or route handler function in event loop. If we don&#8217;t call next at the end of middleware execution the request will be kept hanging and the user will just see the page loading.</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/rr2.png" alt="" class="wp-image-1332" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/rr2.png 432w, https://www.maxester.com/blog/wp-content/uploads/2023/12/rr2-300x67.png 300w" sizes="(max-width: 432px) 100vw, 432px" /></figure></div>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/rr.png" alt="" class="wp-image-1333" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/rr.png 423w, https://www.maxester.com/blog/wp-content/uploads/2023/12/rr-300x230.png 300w" sizes="(max-width: 423px) 100vw, 423px" /></figure></div>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/">req and res objects in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/11/06/req-and-res-objects-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between Sessions and Cookies</title>
		<link>https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/</link>
		<comments>https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/#respond</comments>
		<pubDate>Tue, 24 Sep 2024 13:06:58 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1326</guid>
		<description><![CDATA[<p>Sessions Session starts when you request the server for the first time and it remains till you close that site. The amount of time you have spent on the site is called a session. As sessions get deleted when the&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/">Difference between Sessions and Cookies</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<h4>Sessions</h4>



<p>Session starts when you request the server for the first time and it remains till you close that site. The amount of time you have spent on the site is called a session. As sessions get deleted when the connection to the client and server gets closed, so we have to store the session data somewhere to reuse them again in future.</p>



<h4>Cookies</h4>



<p>Cookies are the information stored on the client&#8217;s browser by the server. It helps in tracking the user and for various personalized recommendations.</p>



<p></p>



<h4>Difference between Sessions and Cookies</h4>



<p></p>



<div class="wp-block-columns has-2-columns">
<div class="wp-block-column">
<p style="text-align:center"><strong>Sessions</strong></p>



<ol><li>Sessions are the data stored on the server side.</li><li>The amount of data we can store on server is very large.</li><li>Sessions are a secure way to store the data as it can&#8217;t be read by anyone.</li><li>Sessions can be deleted whenever required.</li><li>Sessions are used to store confidential informations.</li></ol>



<p></p>
</div>



<div class="wp-block-column">
<p style="text-align:center"><strong>Cookies</strong></p>



<ol><li>Cookies are the data stored on the client&#8217;s browser.</li><li>Maximum size of cookies can be 4 KB.</li><li>Cookies are not secured, as they can be read by anyone.</li><li>Cookies can be deleted whenever required. We can also set expiration period  of cookies, after that period the cookies will get deleted.</li><li>Cookies must not be used for storing confidential informations as it can be read by anyone.</li></ol>
</div>
</div>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/">Difference between Sessions and Cookies</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/09/24/difference-between-sessions-and-cookies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sessions in Express Js</title>
		<link>https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/#respond</comments>
		<pubDate>Wed, 28 Aug 2024 05:23:57 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1317</guid>
		<description><![CDATA[<p>As we know HTTP is a stateless protocol, i.e it doesn&#8217;t stores any data. There are many cases where we have to store the user data to keep track of the user, here comes the use of sessions. When the&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/">Sessions in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>As we know HTTP is a stateless protocol, i.e it doesn&#8217;t stores any data. There are many cases where we have to store the user data to keep track of the user, here comes the use of sessions. When the client requests a server for any piece of data for the first time, the server creates a session for that user.</p>



<h4>How to implement sessions in Express Js</h4>



<p>First of all, install the necessary packages using the command given below :</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessionc.png" alt="" class="wp-image-1318"/></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessionc-1.png" alt="" class="wp-image-1324"/></figure></div>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessioni.png" alt="" class="wp-image-1321" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessioni.png 671w, https://www.maxester.com/blog/wp-content/uploads/2023/12/sessioni-300x224.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessiono1.png" alt="" class="wp-image-1322"/></figure></div>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/sessiono2.png" alt="" class="wp-image-1323"/></figure></div>



<p>Everytime the page you will refresh the views increase unless the server is restarted.</p>



<p><strong>Note:&nbsp;</strong>&nbsp;The&nbsp;above&nbsp;code&nbsp;is&nbsp;just&nbsp;for&nbsp;understanding&nbsp;the&nbsp;sessions,&nbsp;in&nbsp;production&nbsp;level&nbsp;applications&nbsp;you&nbsp;need&nbsp;to&nbsp;be&nbsp;careful&nbsp;while&nbsp;using&nbsp;sessions&nbsp;and&nbsp;cookies.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/">Sessions in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/08/28/sessions-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advantages and Disadvantages of Express Js</title>
		<link>https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/#respond</comments>
		<pubDate>Fri, 23 Aug 2024 05:43:35 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1315</guid>
		<description><![CDATA[<p>Express Js is a web framework used for creating server side code in Node Js. It is a lightweight framework, which offers almost all the necessary and basic features like routing and middlewares out of the box. Nowadays, the number&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/">Advantages and Disadvantages of Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Express Js is a web framework used for creating server side code in Node Js. It is a lightweight framework, which offers almost all the necessary and basic features like routing and middlewares out of the box. Nowadays, the number of organizations using Express Js is increasing rapidly.</p>



<h4>Advantages of using Express Js</h4>



<ol><li>Lightweight : It is a lightweight framework of Node Js for creating web servers. As it is based on Node Js, it offers all the features of Node Js with less coding.</li><li>Time saving : It is developed to reduce the development time which generally takes, when we create applications in Node Js. Express Js provides many features of Node Js in less lines of code. There are many tasks, which in Node Js we have to do manually, but here in Express Js, we have various inbuilt functions available for that.</li><li>Huge Library : Another feature of Express Js is the availability of libraries. As the community of Express Js is large, everyday new packages are getting developed.</li><li>Realtime applications : Express Js is used heavily in realtime applications. It is best suited for realtime user interaction systems, due its non-blocking asynchronous event-driven model.</li><li>Learning curve : As it is based on JS, it becomes easier for developers knowing JS to learn Express Js. Another benefit is that we can develop the whole application (frontend and backend) using a single language.</li></ol>



<h4>Disadvantages of Express Js</h4>



<ol><li>Callback hell: For new developers, it becomes hard to grasp the asynchronous nature of JS. They find it difficult to manage the callbacks. Callback hell is a condition, where we have multiple callbacks nested inside each other and every callback waits for another callback. Eventually resulting a non readable and difficult to maintain code.</li><li>Less features: As it is a lightweight framework, many of the features are not available out of the box and we have to install multiple packages to get those features.</li><li>Lack of strong typing: Express Js doesn&#8217;t have strong type checking while compilation, which results in complex bugs.</li><li>Error handling: Although Express Js has excellent error handling capabilities, but sometimes it becomes hard for new developers to handle errors with the code containing multiple callbacks and promises.</li></ol>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/">Advantages and Disadvantages of Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/08/23/advantages-and-disadvantages-of-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using MongoDB with Express Js</title>
		<link>https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/#respond</comments>
		<pubDate>Thu, 01 Aug 2024 05:45:52 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Node Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1308</guid>
		<description><![CDATA[<p>MongoDB is a NoSql database which is used to store a large volume of data. NoSql database not uses the tables and rows approach. In MongoDB the database is collection of documents, documents are collection of key-value pairs. Javascript developers&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/">Using MongoDB with Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>MongoDB is a NoSql database which is used to store a large volume of data. NoSql database not uses the tables and rows approach. In MongoDB the database is collection of documents, documents are collection of key-value pairs. Javascript developers will find it similar to a javascript object.</p>



<p>MongoDB database can perform all types of CRUD (Create, Read, Update, Delete) operations. We use a module called mongoose to connect to the MongoDB database.</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/connection.png" alt="" class="wp-image-1309" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/connection.png 567w, https://www.maxester.com/blog/wp-content/uploads/2023/12/connection-300x152.png 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure></div>



<p>In the above code, we have connected our project to the MongoDB database. After that we have created a schema, which defines the structure of the data going to be stored. Then we have created a model and exported that to use in the other parts of the application.</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/add.png" alt="" class="wp-image-1311" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/add.png 639w, https://www.maxester.com/blog/wp-content/uploads/2023/12/add-300x164.png 300w" sizes="(max-width: 639px) 100vw, 639px" /><figcaption>Form to create the user</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/db.png" alt="" class="wp-image-1310" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/db.png 499w, https://www.maxester.com/blog/wp-content/uploads/2023/12/db-271x300.png 271w" sizes="(max-width: 499px) 100vw, 499px" /></figure></div>



<p></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/">Using MongoDB with Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/08/01/using-mongodb-with-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Express Js  Scaffolding</title>
		<link>https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/</link>
		<comments>https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/#respond</comments>
		<pubDate>Mon, 15 Jul 2024 05:36:36 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1302</guid>
		<description><![CDATA[<p>Scaffolding is the process of creating the skeleton of the project. In simple terms, the arrangement of different types of files in various folders. For example, managing all the CSS files, js files that we want to be public, in&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/">Express Js  Scaffolding</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Scaffolding is the process of creating the skeleton of the project. In simple terms, the arrangement of different types of files in various folders. For example, managing all the CSS files, js files that we want to be public, in the public folder, different routes in the routes folder, and images in a separate folder.</p>



<p>Scaffolder is the tool used to automate this task. A popular scaffolder for Express Js is an express-generator.</p>



<p>To use the express-generator, run the following command :</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/s1.png" alt="" class="wp-image-1303" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/s1.png 441w, https://www.maxester.com/blog/wp-content/uploads/2023/12/s1-300x16.png 300w" sizes="(max-width: 441px) 100vw, 441px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/s2.png" alt="" class="wp-image-1304" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/s2.png 204w, https://www.maxester.com/blog/wp-content/uploads/2023/12/s2-132x300.png 132w" sizes="(max-width: 204px) 100vw, 204px" /><figcaption>The folder structure of the project was created using express-generator</figcaption></figure></div>



<h4>Folder Structure </h4>



<ol><li>Routes: This folder contains various routes of the application, divided in different files.</li><li>Public: This folder contains the files we want to be public like images and CSS files.</li><li>Views: Views folder contains different templating files that we want to serve.</li><li>app.js: This is the place where all the code is managed. It handles all the other files.</li></ol>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/">Express Js  Scaffolding</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/07/15/express-js-scaffolding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Templating in Express Js</title>
		<link>https://www.maxester.com/blog/2024/07/04/templating-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/07/04/templating-in-express-js/#respond</comments>
		<pubDate>Thu, 04 Jul 2024 10:56:48 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1289</guid>
		<description><![CDATA[<p>Templating helps in converting the content of the static html page to dynamic. By using templating engines we can replace the values in html document with the actual data values. For example, if we want to show the employees and&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/07/04/templating-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/07/04/templating-in-express-js/">Templating in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Templating helps in converting the content of the static html page to dynamic. By using templating engines we can replace the values in html document with the actual data values. For example, if we want to show the employees and their details then we can render the html page with this data using the templating in Express Js.</p>



<p>There are various templating engines available in Express Js like ejs, pug, etc. All the templating engines have their own syntax. In this article we will discuss about ejs.</p>



<h3>Templating in Express Js using EJS</h3>



<p>EJS stands for Embedded Javasript Templating. EJS is used to produce the final HTML document after adding the dynamic content from database or after some calculations. We can also write javascript inside HTML pages using react. We can use almost all the necessary things like conditional statements, loops, etc.</p>



<h4>Setting up the EJS and using it in the Express Js project</h4>



<p>First we have to install it in our project, using the command :</p>



<p style="text-align:center"><strong>npm i &#8211;save ejs</strong></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/index.png" alt="" class="wp-image-1292" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/index.png 603w, https://www.maxester.com/blog/wp-content/uploads/2023/12/index-300x130.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></figure></div>



<p></p>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs.png" alt="" class="wp-image-1293" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs.png 695w, https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-300x110.png 300w" sizes="(max-width: 695px) 100vw, 695px" /><figcaption>indes.ejs</figcaption></figure>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexo.png" alt="" class="wp-image-1294"/><figcaption>Output</figcaption></figure></div>



<p>For using EJS inside our HTML pages, we have to save the HTML files using the .ejs extension.</p>



<h4>Using loops in EJS</h4>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/index-1.png" alt="" class="wp-image-1295" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/index-1.png 374w, https://www.maxester.com/blog/wp-content/uploads/2023/12/index-1-300x195.png 300w" sizes="(max-width: 374px) 100vw, 374px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-1.png" alt="" class="wp-image-1296" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-1.png 703w, https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-1-300x130.png 300w" sizes="(max-width: 703px) 100vw, 703px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejso.png" alt="" class="wp-image-1297"/></figure></div>



<h4>Using conditional statements in EJS</h4>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/index-2.png" alt="" class="wp-image-1298" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/index-2.png 385w, https://www.maxester.com/blog/wp-content/uploads/2023/12/index-2-300x196.png 300w" sizes="(max-width: 385px) 100vw, 385px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-2.png" alt="" class="wp-image-1299" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-2.png 702w, https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejs-2-300x155.png 300w" sizes="(max-width: 702px) 100vw, 702px" /></figure></div>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/indexejso-1.png" alt="" class="wp-image-1300"/></figure></div>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/07/04/templating-in-express-js/">Templating in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/07/04/templating-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error Handling in Express Js</title>
		<link>https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/#respond</comments>
		<pubDate>Sun, 16 Jun 2024 15:04:43 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1283</guid>
		<description><![CDATA[<p>Most of the times, the program doesn&#8217;t run successfully in the first attempt. The reason can be a syntactic error, a logical error or a runtime error. Error handling is useful in handling runtime error. If we don&#8217;t handle runtime&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/">Error Handling in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Most of the times, the program doesn&#8217;t run successfully in the first attempt. The reason can be a syntactic error, a logical error or a runtime error.</p>



<p>Error handling is useful in handling runtime error. If we don&#8217;t handle runtime errors, it will result in the incomplete program termination. Using error handling we can display a message or handle the error, so that the program can complete its execution properly.</p>



<h4>Using try catch blocks</h4>



<p>As we know try-catch blocks are used everywhere to handle errors. But this approach may not handle all types of errors in JS, as JS is based asynchronous methodology.</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catch.png" alt="" class="wp-image-1284" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catch.png 442w, https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catch-300x233.png 300w" sizes="(max-width: 442px) 100vw, 442px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catcho.png" alt="" class="wp-image-1285" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catcho.png 918w, https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catcho-300x68.png 300w, https://www.maxester.com/blog/wp-content/uploads/2023/12/try-catcho-768x175.png 768w" sizes="(max-width: 918px) 100vw, 918px" /></figure></div>



<h4>Using Callbacks</h4>



<p>Callbacks are also a function supplied to a function as an argument. After the completion of that function, the callback function is called. In simple terms, callback functions are executed after the completion of asynchronous operations.</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/callback-1.png" alt="" class="wp-image-1286" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/callback-1.png 429w, https://www.maxester.com/blog/wp-content/uploads/2023/12/callback-1-300x195.png 300w" sizes="(max-width: 429px) 100vw, 429px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/callbacko.png" alt="" class="wp-image-1287" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/callbacko.png 745w, https://www.maxester.com/blog/wp-content/uploads/2023/12/callbacko-300x66.png 300w" sizes="(max-width: 745px) 100vw, 745px" /></figure></div>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/">Error Handling in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/06/16/error-handling-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookies in Express JS</title>
		<link>https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/#respond</comments>
		<pubDate>Wed, 22 May 2024 07:37:14 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1274</guid>
		<description><![CDATA[<p>Cookies are small piece of data that are stored on client&#8217;s browser. These are send with the request to the server and the server also sends back the cookies. Cookies helps us to store the necessary information on the client&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/">Cookies in Express JS</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Cookies are small piece of data that are stored on client&#8217;s browser. These are send with the request to the server and the server also sends back the cookies. </p>



<p>Cookies helps us to store the necessary information on the client side. Later we can use this information for session management, for personalized recommendations.</p>



<p>Cookies also helps the server to recognize the user back, if he accesses the website after some time. In this way the user doesn&#8217;t have to provide the details each time.</p>



<p>Confidential informations must not be stored in cookies, as it can be easily accessed by anyone, through internet or the web browser itself.</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/cookie.png" alt="" class="wp-image-1275" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/cookie.png 452w, https://www.maxester.com/blog/wp-content/uploads/2023/12/cookie-252x300.png 252w" sizes="(max-width: 452px) 100vw, 452px" /></figure></div>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/">Cookies in Express JS</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/05/22/cookies-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Middlewares in Express Js</title>
		<link>https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/</link>
		<comments>https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/#respond</comments>
		<pubDate>Tue, 07 May 2024 07:04:30 +0000</pubDate>
		<dc:creator><![CDATA[Maxester]]></dc:creator>
				<category><![CDATA[Express Js]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=1270</guid>
		<description><![CDATA[<p>Express Js application has a series of middleware function calls. Middlewares are also function, but with some difference, like middleware functions have access to request and response object, they can call the next middleware function. The middleware function takes 3&#8230;</p>
<p><a href="https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/">Middlewares in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Express Js application has a series of middleware function calls. Middlewares are also function, but with some difference, like middleware functions have access to request and response object, they can call the next middleware function. The middleware function takes 3 arguments req, res and next. It is necessary to either end the response in the middleware or call the next middleware function using next(). Otherwise the request will be left hanging.</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware.png" alt="" class="wp-image-1271" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware.png 462w, https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware-150x150.png 150w, https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware-300x300.png 300w" sizes="(max-width: 462px) 100vw, 462px" /><figcaption><br></figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware1.png" alt="" class="wp-image-1272" srcset="https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware1.png 307w, https://www.maxester.com/blog/wp-content/uploads/2023/12/middleware1-300x67.png 300w" sizes="(max-width: 307px) 100vw, 307px" /><figcaption>Output</figcaption></figure></div>



<p></p>



<h4>Why should we use middlewares?</h4>



<ol><li>We can handle the authentication and authorization part in the middlewares.</li><li>We can also use third party middleware like cookie-parser to handle cookies.</li><li>We can divide the tasks between multiple middlewares.</li><li>We can also manipulate req and res object inside the middlewares, like setting the headers of the response object.</li></ol>



<p></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/">Middlewares in Express Js</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2024/05/07/middlewares-in-express-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
