All right so uh welcome back to the session in the previous session we were discussing about uh this spring MVC concept where uh in that system you know I did not uh get the output so what I will do is the similar code which I had the same thing I will uh try to show it to you here and then we'll try to execute it so uh I have a project here which is MVC Spring whatever the code that I had explained uh the other day the same code is here as well so if I
get into my Java resources SRC I have created a couple of files and then uh resources and pom.xml first I start from the pom.xml in the pom.xml I have uh spring web MVC which is 5.3 21 Java X seret jstl dependency which is 1.2 Java X serlet API 4.0.1 then uh this is some different dependencies which I've added slf 4J API and slf 4J log 4 dependency this is for logging but uh after that I have added the hibernate core dependency and MySQL connector jar dependency with spring cor and spring context as well spring omm
I added because I want to interact with the database I want to insert the data into the tablee so this is what I have Added and hibernate jpa 2.1 API dependency these are the dependencies that I have added now I'll get into my uh XML file here which is my hibernate.cfg.xml so in the hibernate.cfg.xml I have told which is the database that I need to connect to I've told here is iberet J is the database see if you want you can again uh make hibernate to ddl Auto as update which means automatically it will create
the tables Etc now I will get Into my uh application which I have I have a employee entity class this have added hibernate here so employee entity class maybe I will call the table name as employ 1 2 3 because I have made it as hbm to ddl Auto as update it will create a new table called as employe 123 table in which employe 123 table I have told I need ID I need column as ID then uh I I have integer EMP ID column name is EMP name String EMP name column name is designation
I have string name and Column name is salary I have salary then zero parameterized Constructor parameterized Constructor and other details I have I have not made ID as autogenerated value if you want you can make ideas autogenerated value so apart from this I have employed Dao in which I have insert method fetch all and fetch specific methods so I have employ Dao implementation where I needed a session see whatever session I needed I got the session as Auto wir you can see I am making use of uh uh employe Dao implementation Constructor in which I
am saying it as Auto wired which means it has to be injected what value has to be in ined session Factory qualifier should be injected where is this mentioned sir I have mentioned it in my configuration class as app configuration. Java is the class here I have told boss I need a session Factory so whatever session Factory it is there it is going to give me a local session Factory see again I'll tell you this code is a boiler plate code is what we call which means it is a code which will repeat in many
any applications you can find it on the internet you can just go and say I want a bean configuration for a configuration class called a session Factory Bean configuration you'll get the code available right nobody will write it nobody will hard code it any time so I am using this uh configuration you can see what is there here if you ask me I'm Using session Factory Bean do configure local uh thing and you're using class paths resource which is your resource file hibernate.cfg.xml you know why we use it we use it to make use of
the uh data whatever is there to connect to the database username URL password all that is present in this particular file right okay sir then I'm returning this session Factory Bean whichever I have created here right in the same way I've also told was there is some component scan That has to take place the base packages are com. tab. Dao and com. tab. entity com. tab. Dao and com. tab. entity these are my uh base packages then I will uh get into my front end which I have so uh SRC main web app web I
I have a dispatcher serlet I have a web.xml first control will come to the web.xml in the web.xml you can see boss I have told there is a dispatcher serlet for a URL pattern forward slash the Dispatcher serve letter is dispatcher at this particular file and now the control will go to the dispatcher servelet whatever I have created in the dispatcher serlet I have told where is the component scan supposed to happen right so the component scan the base packages com. tab. controller because this is where my controller file is present right apart from that
I am saying my application is MVC On annotation driven and uh also I'm saying there is a bean class for internal resource view resolver with uh prefix as a web in/ JSP suffix as. JSP if you want you can rename it to view and rename the folder to view also not a problem now uh in this I will say which is the first file to be called let me look at the controller controller I have one controller here called as the home controller so I will say here boss uh This is my uh controller called
as the home controller in this home controller let me remove this let me comment it for now I'll tell you what it is so there is a controller that I'm writing for enter data as soon as I say it as slash enter data where should the control go control should go to a file called as collect data uh let me see where is my collect data. JSP it is there in the JSP folder collect data. JSP I will go to this collect data. JSP Collect data. JSP is a collecting ID designation name and salary then
it is asking me to send data as soon as I click on send data control will go to the controller saying it as send data this is the controller where I am collecting all the information I told you this is the where I'm writing the control by saying request mapping or request parameter of ID give it to ID request parameter of designation give it to designation name give it to name Salary give it to salary now I also need model what is the use of a model it is like a session to store the data
how I have session in my seret model is like a session it is a memory storage so I will make use of a session I will I I make use of a model first I will see which all data I have got I will print the data after that I'm creating an object of annotation configuration application context I will give the app configuration file where I have base Package mentioned I have session Factory mentioned all of it now you can see I will ask my application context annotation configuration sorry application configuration application context to give
me an object of Edo which is nothing but Dao implementation it will give me an object then whatever object it is going to give me I will collect it in Edo I or Edo I'll ask for a employee bean Employee Bean is using zero data there is no data inside the employee beam now I will set the data using Set uh once I have set the data using a Setter I will say Ed aoi do insert which means control will now go to the Ed aoi see in the Ed aoi already Constructor is called when
the Constructor is called you can see the data is auto wired the qualifier is auto wir which means session is ready so insert method will accept employee I will say create a session using session Factory create a session then begin transaction purs the object commit the transaction close the session now I will just come back uh control will come back here now I will say boss you add the name into the model and then call return to display data now control will go to the display data in display data I'm saying thanks whatever is the
name data is received now I will just save my code I will go to my application right click run as run on The server see in between all of this there is one index.jsp page which is displaying all this information so now this index.jsp I will say start app so I just want to go to the index.jsp I just want you to see tell me start tap which is the first mapping enter data so previously I had something called as home Etc I will add it back and show you so now I will say spring
MVC sorry MVC spring/ enter data is my URL now so now I will just save it I Will just go back to my application refresh it so now you can see here I'll click on start tab as soon as I click on start tab you can see control has gone to Spring MVC SL enter data I'm now supposed to enter the data let me go to the uh uh database which table is it connected okay it's a new table employee 1 2 3 is a new table I will click here as ID as well one
designation is trainer name is akill salary is 10,000 I will now click on submit before I click on submit let me go to the database you can see I was connecting to hibernate J so this is my hibernate J table employe student student sequence is what I have now I will hit submit a new table should be created called as employe 123 so once if I click on submit it is saying thanks aill data received if thanks aill data received is displayed you can see what is happening in your application Here so see here it
is asking the employe mean it's creating a table called as employee then uh it is inserting the data into the employee 23 if I go to my database now refresh my database is employ 23 not created where is that I'm connecting to where is uh hibernate do Local Host SL hibernate J only this all created a table Here I'll uh reopen the workbench why is it not entering let me do a thing maybe I'll write a success message somewhere so that I can see if it is really successful comment is also done so if this
executes it should be successfully inserted maybe uh I'll change uh J12 is what I will say a new database Only I will use a new schema hibernate j e e one to apply apply and close it finish it now uh go back to my application right click on my project run as run on the server one trainer akill 1,000 10,000 submit so it's not giving me success message here right it's not giving me the Success message which means it is not able to insert the data what is the reason I'll try to print the employee
here to see what is the employee detail that I get so I will say here as one employee I'm Printing and two I will print uh session I'm just assuming if session Could also be null let me just check run as run on the server trainer aill salary 1,000 submitted it's saying ail data received so trainer object is there session object is also there no problem with uh getting the session session do begin transaction T do commit hibernate j e E12 no table here I've closed it and restarted it okay probably there could be some
exception because I'm not printing it exception. print L print stack Trace right click run as run on the server I'm assuming there could be an exception submit there's an exception does not exist AA so it is not able to create the table it is asking uh could not execute the statement because SQL grammar exception I did not write any SQL [Music] grammar persistence exception or GSL grammar exception could not execute the statement home controller employ Doo implementation commit method here it is having a problem and it also says table does not exist so let me
create this employee 23 table let us see if uh creating the Table would help us so let me go into the database hnet J12 under tables I'll say create a table employee 1 2 3 what is the ID I guess employ do Java I guess I've written it as ID here ID is a integer primary key then uh EMP name Ware then uh DG D SG is workare salary also I will make it as Ware now I will tell it here is apply and apply it finish it so you can see Under the table section
employ 1 2 3 table is empty now let me try to re-execute my application right click run as run on the server start application one trainer akill salary is a 10,000 submit it says thanks let me see if there is any exception now now there is no exception it says it is Success which means data should now be Inserted so you can see the data is inserted probably because uh it's is not able to create a table on its own that could be a reason for it so now this is what I am doing here
uh look at the URLs that I'm using spring MVC spring send data then some data anywhere are you able to see the dot JSP file will you agree who is displaying this information display data. JSP was the One who is displaying this thanks cill data received but in the URL is it saying which is the JSP file the reason is very simple see all these uh whatever you use here with respect to your uh what I can say is uh spring boot application or your spring applications they are secured applications which is the file name
will not be exposed whatever this slash data is There is it a file name it is get mapping URL that's all sir it is not a file name why because this is a secured way of writing where none of the file name is exposed here if I say send data do you know which is the controller who is called I don't know it sir so you would have seen people uh create websites you know if you just have a look at it your food delivery app at what time in which file you are you can
easily say Sir this is checkout. JSP sir go to checkout. JSP this is menu. JSP sir why because you have directly written it but in Spring we will not be directly writing it we will map it callif basically your spring MVC one major advantage of developing any application using spring as a controller is the file names are not exposed right this is one of the use case now you would have seen assume that there is an application Now and whatever the application that I have for example let's assume the food delivery app that we have
so if I say food delivery app as a whole right let me say it as FDA food delivery app if I just have to tell you can I divide my food delivery application into smaller segments I will say boss there is one functionality that uh we have worked on which is The customer side of the application whatever we have done is all customer side of the application along with the customer side there is also admin side of the application which partially we did like add a restaurant add a menu delete a restaurant delete a menu
update restaurant update menu that we have done so along with this there is one more side which I can call it as uh Delivery Agent site but we haven't worked on all these we only worked on the customer side will you agree with me now assume that customer wants to log in I will create a page called here as uh login do HTML maybe admin wants to login for admin also I will create a Page called here as login. HTML then I will create Delivery Agent for the delivery agent also I will create a page
called as login. HTML now how will I call this page login. HTML according to the project that you have written sir it is a food delivery app SL login. HTML sir will you agree with me now I will write in the URL in the URL I will write here as ww W www. uh Local Host colon 8080 SL food delivery app SL login. HD so as soon as I write it like this as food delivery app SL login. HTML won't you agree with me in my project there are three login. htmls now which login. HTML
do you want to call don't you feel this is a Confusion so in order to avoid this confusion I will say Sir whatever are the files inside my customer to call these uh files inside the customer I will say slash customer SL login. HTML to call any file inside admin I will say slash admin slash login. HTML to call something in the agent I will say agent Slash login. HTML sir I want to call it like this which means all the files inside customer should be prefixed with Slash customer all the files inside admin should
be prefixed with Slash admin all the files inside Delivery Agent should be prefixed with SL Del agent I hope you're able to understand this right so how will I do it sir in order to do it I will say boss if I want to enter Customer you need to check for one mapping what is that mapping I will say here as at theate request mapping for customer so it will be request mapping slash customer slash to come come here some uh mapping I would have used to call the login. HTML what is the mapping slash
login let's Assume so/ login we call this file called as the login. HTML yes or no in the same way here also I will say at the rate request mapping for slash admin slash login so that is what I was trying to do there so now imagine there are two controllers now in my project there are two controllers so just to help you understand let me just stop this application here have a look at it there is one controller which is called as the Home controller this is my home controller which I have and for
the home controller whenever I want to call the Home controller I will say at the rate request mapping as SL home tell me now if I want to come to this enter data file can I directly say slash enter data I'll show it to you so see here your uh index.jsp what is your index.jsp calling MVC spring SL enter data now let us uh run this application now let me Just show it to so what is it calling spring MVC spring/ enter data now I will click on this what does it say 4 not4 not
not found which means it is not able to find slash enter data why sir see the first thing your uh program is now going to do is it is searching for the controllers so tell me here I have one controller called as home controller because all the controllers I told I'm Writing it inside com. tab. controller you remember in uh my uh dispatcher server let I have written where all the controllers are present com. tab. controller so first it will come to the home controller it will say hey do you have enter data the first
is here the controller it will say hey enter data I don't have if you want to enter you tell me do you have forward SL home I don't have forward SL home if you don't have you cannot enter now it will Go to the next controller which is there called as a student controller it will ask the student controller hey do you have for/ enter data this will also say B for/ enter data is not there do you have forward SL student first of all I don't have so my code is's saying I don't find
it now in order to go here tell me where is uh for/ enter data sir for/ enter data is in this file called as the home file sir if it it is there in this home Controller first of all I need to enter the home controller how will I enter the home controller first of all I should have a mapping called as forward slome if forward slome is there next what is the URL pattern I can search for so to have forward slome I will go to my index.jsp here I will say MVC spring/ home/
enter data when the user clicks here you go to this URL home/ enter dat I hope you understand this now I will just save my Code I will rerun I'll stop the server and rerun my application now now you can see I have start I'll click on start look at the URL what is it MVC spring home/ enter data now I will enter all the data sir I will enter the data ID as a two name as sorry designation as trainer Rahul salary is 20,000 now I will click on data sorry submit where should the
submit Go sir look at this enter data was uh calling a File called as collect data. JSP collect data is calling send data so where should the control go now MVC spring/ send data or MVC spring home/ send data where will it be called MVC spring home. send data is where logically I want it to be called sir yes or no let me see what will happen if I submit it is calling MVC spring home slash send data why is it because it is taking this Slome as a route till now your route was only
MVC spring once you enter into the home now it is home sir I want to go to the student controller sir I want to go to the student controller for that case here I want to give one button click here for student controll I order to do it what I will do is uh which page is this uh display data. JSP here after saying data is received I will write a Br tag here I would say boss anchor tag a hre is equals to and then I will say it as uh go to student tell
me if data has to go to student just like how I wrote it in my index.jsp in the same way I will say MVC spring slash okay MVC spring slash uh for student controller what is the mapping slash student I'll write SL Student slash e data slash student slash e data correct now e data which file is it calling student page is it it is calling student page in the JSP do I have student page yes sir student page. JSP is there so let me see if that page will be called or no now I
will just go back I will refresh this you can see it says go to student if I click here you can see it is saying MVC SL student SL e Data welcome student I hope you're able to understand this sir now I want to call one file in the student data that is in the slash student mapping I want to call a file which page student page. JSP I will say here as uh a hre is equals to I will say here as click here now I will say was where should the mapping go uh
the mapping has to go to uh was I using forward slash I don't use a forward slash so I will say the for You know the mapping has to go to bring me a new file the mapping has to go to bring me a new F now I will just save this I will go back to my page if I refresh it is saying click here I will click here so the URL has bring me a new file but it is saying what there is no page found for it why did I write any mapping
for bring me a new file in the student I did not write sir will you agree with me so my duty now is to write A mapping for bring me a new file see forget about writing mapping for bring me a new file there could be cases where the programmer May randomly write some uh URL if I hit enter whenever you're using any application is it right or is it good to have a file not found page Amazon amazon.com let me just open amazon.com here I'll say open amazon.in so in amazon.in what I will do
Is I say amazon.in SL some URL SL some URL some random URL I will write tell me in Amazon do you have a page like this not necessary sir now if I hit enter is it giving you a file not found the internal server could not file this find or is not is not able to you know accept that it this one exist Etc it is saying B looking for something you know whatever you have entered such a file is not there so you please click Here to go back to the homepage don't you feel
it's good in some pages you know you'll see a dog image in Amazon right this file does not exist some problem go back click here sir it would be better if my application also has it sir what is this sir status file not form are you able to understand this to write such a code now I have to say bus in the student controller if somebody is Saying slash e data you call student page no he's not saying slash send date student page or E data there could be some type of random Ur for such
random request mappings how will I write about random request mapping I will say forward slash double St this is a random request mapping whenever I have a random request mapping you please call public uh string error page method where I will will say return return error Page return return error page now it is my duty to create this error page so I will click here I will say uh I'll go to the JSP part right click new JSP which I will call it as error page I will finish it now I will say some internal
error I will I'll now just save it go back I'll go back refresh okay so I guess uh I have Stopped the server somewhere or I'll restart the server let me restart the server right click run as run on the server so I want to go to the student go to app maybe here only I will add it as slash e data for the student or maybe I will write here as student slash some random URL I'll remove all the blank spaces some random URL I have Entered if I hit enter you can see some
internal error page maybe whatever you want some image whatever you want you can add write a button below saying go back to the homepage right go back to the hom page now I will go back to the homepage sir what if I'm having an error in slome slash some random you word here instead of saying it as a slash student slash random URL I will say slome slash Random URL if I hit enter it will say file not found why it will go inside the home controller inside the home controller I'll now say here boss
page not found you call if there is a random URL you call a file called as page not found now I will refresh this I don't feel it can refresh maybe I'll have to stop the server and restart it right click run as run on the server so I'll write here start app it Will go to the home/ enter data in the home/ enter data I'll write some random URL and once if I write some random URL it is called a page called as page not found where in the page not found I have displayed
no such page so you can see page not for No Such page is what I have deed I hope you're able to understand this right so in the same way maybe in case if you want to fetch data you can make use of uh employee Dao implementation in this uh employee Dao Implementation you have have a fetch all method which is going to fetch all the data and displayed to the user only thing is it will be giving it in the form of a list that list you have to display it in your JSP then
uh fetch specific will give you one single user you can put this user into a model and from the model you can bring it into the JSP and displayed by saying see if you're using an employee object e if you are putting employ object into the model You can display it by saying e do get employee ID e do get name you can write it inside your GSP to display you can make use of those expression tags and write it I want you to try that part of it where you are trying to insert the
data and uh sorry fetch the data and display it using a JSP so if you try to display it display all display specific edit all and sorry edit specific and delete specific is again the same because delete more or Less is you'll take the ID give it and it has to delete it's a repeative task I want you all to try this will you all try so uh right so after this uh there is one small concept of I mean one small program that I want to write for spring boot as well where we'll perform
crud operations so spring MVC cred I want I I have already WR the code here for fetch all and fetch specific it's nothing you know it's again hibernate code only here and whatever hibernate code you will Call you will take it into your controller add it to model display from the model that's there's nothing new here it's just a loop that you have to run and displayed I want you to try it because it's a similar repetitive task so uh what I want to do is I want to write a crud application using your uh
spring boot but uh you know the entire application I will not be able to write it today today I will give you an introduction maybe tomorrow I will uh arrange for some online session at least or I'll see if I can get this classroom at the same timing we will do an offline session but I'm sure most of them are not attending offline while I'll anyways ask for an offline session even if uh students are joining uh through online I would be happy about it but right so what is this spring boot is something that
you need to understand But before I actually talk about uh Spring Book I want to talk about the Journey of as writing a Java program to interact with the database first I started off from writing jdbc Java database connectivity where everything was console based I will enter the data I will hit enter control will go mean data will be sent to the database and I will get a success failure message then slowly I switched To something called as D AO not J D sir what is that I was doing in Dao sir I was not
entering primitive data as a user I was creating an object giving it to a doo class that do class used to open the object take the primitive data and insert it but for or the user it felt as if object was inserted then I slowly moved into the jwe part where I asked the user to enter the data on a browser whatever the data the user was entering I used to take it Into the controller there we follow something called as the MVC design pattern where from the mod sorry from The View controller used to
collect the data take the data create an object give it to the model in the model I had the Dao implementation classes which were again going to the database inserting giving back success or failure your controller was deciding whether a success page should be called or a failure page Should be called so this is what we did when it comes to the jwe part right and slowly from the jwe we move towards hibernate in hibernate if I have to tell you all of a sudden right from writing uh hundreds of lines of code in my
uh Ser in in my uh JW jdbc part my code reduced in hnet but still there were some lines of code I had to write some hql queries I had to create when it comes to the hynet then slowly I moved toward Spring in the serlet whatever I was doing most of the code reduced in spring now I took the data created an object gave it to the D implementation now I am moving into the next part which is called a spring boot in the spring boot whatever little amount of code that you are also
writing in hibernate I will not be writing that little amount of code also one method two methods two lines one line is what I will write to insert The data or fetch the data sir how is this possible sir if you ask me see just to help you understand in my spring boot how my spring boot application would work see again if I say spring boot is it a front end or a back end of an application spring boot is basically a back end of your application front end will be separate so if I just
have to tell you this is my back end of an Application and uh this is my front end of an application see basically if I just have to tell you whatever the back end of an application that I am saying here let us assume I am writing the back end of this application in uh Eclipse sir I will use Eclipse to write the back end because uh I am more confident or eclipse is very friendly to write Java Cod sir but when I try to Write front end in Eclipse I don't find it so easy
or it is not so user friendly sir so FR and I will write it in uh Visual Studio code sir if you want if you using a spring boot application you can write back end separately you can write front end separately basically if I just have to tell you here if I write a spring boot code here if I write a spring boot code front end see you can use the JSP Etc but not Advised front end it is always advised either to use uh angular or uh react or uh vuejs all these are something
that is uh advised to use why because of framework or a library is always friendly with a framework or a library is always better to use a framework or a library with your framework or a library if you say Sir one side I will use framework one more side I will use JSP framework very little coding jsps or HTML so much of coding will you agree with me today if I say you hey now you have understood how to write the code why don't you use spring with JD BC I can write sir spring with
jdbc but will you write sir hibernate is easy sir why should I go to jdbc in the same way when you learn these frontend files or front end tools like angular react or any such frontend Library or a framework writing code in just HTML and CSS or JSP is pointless because or any advanced concept goes well with the advanced concept so now what I would say is I want you to choose either of these and start learning react is a better option compared to the number of openings that is available in the market but sir
far now I don't know angular or react sir so far now you don't know angular or react let us remove the front end I will Not have the front end in my application sir if I don't have a front end in my application what will I do sir see in Spring boot I want to write five features called as fetch all data fetch specific data then uh insert all insert data update data delete data these are the five operations that I want to do so in order to do these five operations some lines of code
would have written these are the lines of code for Insert these are the lines of code for uh fetchall these are the lines of code for uh fetch specific these are the lines of code for update these are the lines of code for delete now if I have to call a insert method how will I call a insert method sir some mapping should be there Sir URL mapping we just saw it in Spring if this URL is there call this method if this URL is there call this method so I will say boss in order
to call the insert method there should be one Ur are maybe let's assume this application is uh related to book I will say book app slash to insert the book you should call a method called or a URL called as Insert book URL you should call a URL called as insert book in the same way to fetch all books you will have to call slash book app slash bring all let's assume so in the same way to fetch a specific I would say slash book app slash bre ring one in the same way for update
slash book app Slash modify I would say similarly for delete I will say slash book app slash remove see while you're modifying you need to say based on what Det do you want to modify like say slash id/ ID bring one also slash ID this you'll have to anyway but these are the URL patterns which I need to be calling if I call this URL pattern I Should be able to insert a book if I call this URL pattern I should be able to fetch books if I write this fetch one if I write this
update if I write the other URL delete see whatever this URL patterns that I'm talking about what is this URL pattern helping me to do it is helping me to interact with my application will you agree with me hello it is helping me to interact with the application which means can I say it is a Medium it is a medium through which somebody outside the application can interact with your application somebody outside the application can interact with your application such end points which are available in an application to interact with the application these are only
called AS apis application programmable interface it is an interface for my application it is an interface for my Application application programmable interface where I can interact with my application take data give data Etc see one basic example for an API if I have to give all of us in our mobile phones have an app called as the weather app what is that weather app if you open the weather app what all information will the weather app give you sir the weather app first and foremost thing it will give me the highest temperature today lowest Temperature
today highest temperature it says it has 24° and lowest is uh 20° it will also tell me what is the rain condition if it is uh if it feels like it is raining in the animation in the background it will have some rain droplets if it is sunny outside if the temperature is sunny outside it will have a cloud with bright sun right it will also give you you know if you look at more details it will also give you about what is the wind temp Wind speed at what speed is the wind moving the
speed of wind humidity water level everything it will give you so now tell me I want to C calculate the speed of wind can I simply stand like this and say the wind is blowing at 20 km/ hour sir there has to be a equipment which will keep rotating and the number of rotations it takes per minute or per hour will decide the speed of the wind sir will you agree with me similarly if I have to say what is the temperature average temperature can I simply say and say this is 10° 20° you need
a reader for it sir maybe if I have to calculate a human body temperature I'll need a thermometer similarly for environment temperature also if I put a thermometer it doesn't actually work I need some other device which will calculate the temperature levels will you agree with me now if my mobile is able to tell all of It is a thermometer put in my mobile is that uh wind speed calculator put in my mobile humidity levels if I have to say in this air here there is uh 40% of moisture does uh that device is it
put in my mobile then how is my mobile able to tell all of it sir there is one weather station sitting somewhere who has deployed all these devices All Around the World in Bangalore he would have put it in some centers you can watch them whenever you are traveling you know you could see over the uh traffic signal there will be this uh thing that rotates which will calculate the speed so they would have deployed it in some areas for example you would have seen people say oh there is uh 20 mm of uh rain
in Bangalore 20 mm rain in Bangalore what do you mean by 20 mm rain how is it Calculated what is this 20 mm how what is exactly 20 mm see there will be a station where they will have this uh we have this in the chemistry Labs we used to have this uh test tubes they would place a test tube outside in a place where there's nothing over the top and when it rains how much of water is you know accumulated in it that is the number of mm of rain so if the test tube
is filled with 5 mm it is said that oh it is a 5 mm rain if it is filled at 20 mm it's a 20 mm rain so does that device be present inside my M there is somebody who is accumulating the data and putting it in into is application now he will say boss you want to see the temperature where in Bangalore you send me the longitude and long you know latitude and longitude of Bangalore based on that I will do some Calculation I would have stored the data in the database I will bring
the data I will send it back to you he is giving me an API he's giving me an a API just to tell you you know there is uh one small uh API vendor which I want you to explore it today see if you give the thing to chat GPT it will help you with the code I just show you there is an API called as uh open weather map API so uh what it does is it is going to Help you with uh not this open weather map okay API documentation you have did they
change the entire uh Ur okay see for this you will need to just like how for your GitHub you need to bring the access token in the same way you have to log in here and bring an access token for this once you bring it you can say here your first query what should it be it says boss you have to enter Https colon api. meats.com give the date and time in the right version then sltm Etc what is this uh value I guess this is supposed to be a latitude and longitude values so you
can see here it says what is this this is the current date and time based on your Zone then uh par meter with unit temperatures at 2 m above the ground in De C okay latitude And longitude in decimal degrees you have to bring HTML in which format do you want the output to right use a time interval so it is also saying you in case if you want it but see basically what I'm trying to tell you there was one more okay this open weather map .org okay so both of them I guess are
similar openweathermap.org this is open weather okay this is met matatics okay this is a sponsored One that's the reason it's above this so this is the uh URL I mean this is the thing so this has a free usage which means you can uh log for free you can hit URL apis for free so if if you get into the documentation for API you can see here you have option at the top called as API if you go to the API you can say boss uh there is a professional current weather app howly forecast I
need a current weather app so if you can open it this is the URL that You have to hit if you hit this URL he will give you some information that information you need to process it and display the information is basically in Json see any API the data it is always preferred to get it in Json format because Json is uh easily used or Json files can be easily used by your uh react angular all these frint and Frameworks right either a framework or a library it is easy to use uh Json format so
what I would would do Is I would say maybe if you hit this API so it is saying boss this is the API that you have to hit enter the latitude longitude and API ID key API ID key is nothing but your token which you have to log in and generate so if you log in and generate I guess this is uh free for 15 days or uh 2 months something like that it's a free usage uh tool for a couple of days you can can use it you know if you can give this to
uh chat GP and say here I want To hit this Ur I want to hit this URL using J let's assume what is the code to write so it is saying B there are some URLs or some dependencies that you may need to bring then it will say API URL you need latitude your latitude you need to calculate your longitude you need to calculate then API key you have to generate your API key once you generate your API key it is a web Target what is Your web Target I would say the web Target is
client Target is API URL in this there is some parameters latitude parameter longitude parameter API key parameter those you set latitude longitude and API that I have collected it here and I have kept it here right uh then I need a response Target you get a you hit the target it will give you a response whatever response you're going to get check if the response status is 200 see 200 response statuses perfectly Working 4 not4 file not form 500 internal server error so if this 200 perfectly working if it is perfectly working I would have
got back some data so whatever the data that I have got back it is a Json response converted to a Json response accept the Json data print the Json data so it will give you the ID URL etc etc etc I hope you understand this I want you to try here all you have to do is just replace your API key you have to Log in there get the API key put it here and uh you will be able to display the or handle the Json data and Json data is basically like this when you
call Api accesses succeeds it is going to give you such information what is the temperature see usually whenever you see it will say boss temperature is 20° but there is so much of humidity you go to the coastal areas you won't see scratching heat there it will still be 20 25° but you will feel as if it is 30 35° because water humidity is less I mean the water content would be less in the area so you go to a hilly station though it is 10° or 12° you'll feel as if it is freezing cold
you'll say maybe it is below 0° why because there the moisture levels because once it is in the hilly area clouds which will pass by they'll all be cool enough that you'll feel it is very cool so this is temperature is a 282 Fahrenheit is what I believe they're Given it and it says it feels as if so and so minimum temperature maximum temperature the pressure humidity and all of the other details in this way is what you'll get the data you can just print this much and later you can put it to your front
end you can uh say only bring temperature display temperature based on temperature decide the image that you want to display if the temperature is below 10° put one Freezing image if the temperature is above 10 above 15° and Below 20° maybe put one Cloud cloudy image if the temperature is above 30° then display a scotching sun like that something like that I want you to just give it a try right so uh what I'm trying to tell you is apis are very common when it comes to the industry see assume that you are working you
you have been put into a project maybe your duty is to work work for a Client called as kotak Mahendra who is a bank now as a developer your work is to analyze the data of kotak Mahindra as transaction on a daily basis so when you want to do it on a daily basis you would write one script you would write it such that every day at this time this script should start and it should fetch all the data it should perform some operations whatever the operations that You are performing will you do those operations
on the live database at kotak mahra server sir live database if I do assume that my duty is to work on the client's loan uh feature you know credit card assume that I'm dealing the credit card details by mistake instead of saying select star if I said delete everything all the customers are happy Sir customers would anyways be happy but what about the bank so none of them will give you access to the direct live server they will say bu you want data you want data at 130 now you hit one link I will give
you all the data you download it on your local computer on this local computer you write the script let the script work if it is successful then put that script onto the live server nobody will make changes in the Life you know uh I used to have a manager you know he was like experienced like 20 25 years he used to write code on a live server even if one small thing changes the entire application is on a Hal because it is on a live server but again if you say sir I will also make
changes in the live server nobody will give you access to live server so very very rare cases if it is uh there is no other Option only then you have to write code on a live server it is like doing a open heart surgery even a small mistake the heart will stop working you know it's basically like there was a meme that comes out uh a mechanic and a doctor will keep talking I will also work on the heart of the bike you also work on a heart of a human what is the difference the
doctor says do it while the engine is Running because your heart is running and the doctor has to operate right so similarly like that so nobody will give you access to the live server so you need to pull your code to pull the code you need to hit a API hitting a AP will give you Json data collect the Json data put it into a form into a database local database then work on that local data so now interacting with apis calling apis Is very common so you have to do it for that what you
have to do is you have to learn a couple of such examples now sir you are saying in spring board I'm not going to write front end I'm only going to write the back end now whether this back end whatever I have written is it working fine or now how will I check sir will you agree with me in the industry also such requirement is there there could be a developer whose Duty is to write the back end code he knows nothing about fr content see whenever you start talking about development process in the industry
it basically runs as a Sprints assume that food delivery app I want to create nobody as we created our first login FR end login back end register front end register back end nobody will create it like this whichever team is ready they'll start assigning the work to the team they'll start getting the Work done basically we will always prefer starting the back end of the application because once the back end is ready then we will start designing the front end now imagine I a backend developer I have completed all the back end work I want
to check whether the code will work or no there is no option for me to check because there's no front end should I wait for the next 6 months till the front end of the application is ready to check if the back end and front End are working fine no sir I need to write this URL immediately after writing this URL I need to check whether it is working or not if there is a problem then and there here only I need to rectify imagine the insert method I would have written it today for me
to complete the entire back end it would take 6 months then the front end developer to develop the front end 6 months almost one year is over by that time I don't even remember whether This I wrote or anybody else wrote yes or no debugging fixing the problems while you're writing the code is good you would have seen this you know when you open your Eclipse there will be so many projects on your left hand side where so many projects will have red dots errors if I say what is this sir that was old error
sir this is recent sir this is this error what it is I know how to tell but all those are old projects I don't remember what those Errors are in such a way imagine if project is uh taking 2 years 3 years what will he know forget about whether he knows it or he doesn't know it what is the guarantee that employee will still be in that organization so then and then I need to check whether the code is working fine or no in order to do it we don't have a Fred but we have
a tool which can mimic as if it is a frontend request where I can hit a URL get data Insert data update data delete data which is only called as uh postmen right so what I will do in tomorrow's session is I will write these URLs I'll write this apis and then using Postman I will hit to check when I hit bring all is it bringing all the data or no when I hit uh bring one is it bringing one data or no if I hit modify is it modifying if I hit insert is it
inserting I will write a code to check all of it and checking I'll be doing it Using post is that clear so maybe for today I'll halt it here tomorrow one last session I would need where I will finish this see this is not actually there in our syllabus but I'm trying to add a little of additional spring boot content as well because uh whenever you go to any interview there is one or two uh such interviews where they may ask you to have basic knowledge at least at least a cred application knowledge There was
a drive for a company I'm not sure neap or niap so they had given a requirement for a spring boot project cred application only only thing is while you're doing this cred application you also have to do one to one m with one more table Card application one to one mapping what is one to one mapping if you one if you bring one data from one table one more Row from another row another table should also be fished That's all code everything will remain the same only thing is you would have written at theate 121
if you write that at theate 121 your duty is over so I just don't want to miss out on such opportunities so that is the whole reason why I want you to try attending the session make sure you attend the session even if you're not attending try attending online at least I will take it even if the class is empty because at Least the recording will be there so that you can watch it at a later stage also right if you are available if you are nearby come to the class and attend when you attend
the class online and when you attend it live there is a difference and also this is one such concept where it is very simple I tell you 1 hour one and half hour I'll be able to finish all five apis and when you put it into your Resume you'll be able to explain about it for that you can also say Sir for this I can add one to one see assume if it is a book application I have a book entity for that book entity I will also have author entity assume one author can have
many books one to many mapping sir I can write like this sir you can go go to an interview and say sir when I started this application I started with with a thought that I will add mappings and all of it as of today This much have completed my plan is to bring one author entity one author can have many books one book belongs to sorry many books belongs to one author one to many many to one annotation then one book has uh ratings it is one to one mapped so something like this when you
talk about it at least you know you'll have an idea to talk and express it in an interview you can tell sir very simple sir everything I have written only thing is There I should add one to one here it should add one to many many to one just The annotation part is left out if you're very confident on hibernate and spring this attending interview and talking about this in interview is a very simple task so make sure you don't miss out practice this as right for today I'll halt my session here I'll see you
in tomorrow session one last session tomorrow right thank you so much everybody