 Welcome back to the video, Servlet Request and Ling. In this video, we are going to study Servlet Request and Ling. I am Professor Dattadriy Gadmal from Valchand Institute of Technology, Solapur. So in the previous video, we have seen how to write a Servlet program in Eclipse. Now let us see Servlet Request. What will be the learning outcome in this video? At the end of the session, students will be able to write a simple HTML page to pass data to Servlet. Now, Servlet is not only mean to write a program directly, we cannot, we don't intend to write a Servlet program directly. Instead, user writes a HTML page and passes the data from HTML page to Servlet. So that Servlet Request will do the thing. It will take the data, process it and send back the result. So this is how Servlet is usually called, not directly. So HTML play an important role over here. HTML pass the data to Servlet. So let us see about all these things in detail. Don't worry. Servlet Request Interface. Why Servlet Request Interface is required? We have to initialize and we have to declare that what type of Servlet program you are going to write. So here basically I am going to use the methods inside response and request like content type, content length, parameter name, and attributes, etc. So these are all the things client information is required. So to avail the client information, so what kind of page it is, what how much the length is. So this all things can be identified and can be gathered this information through this particular information like content type, content length, parameter names and attributes. We will come to this later. Now what are the different methods inside Servlet Request Interface? These are some important methods which are present inside Servlet Request Interface. So when I want to pass the data from HTML page to this thing, Servlet, then I pass the data using these methods. And those data is collected at Servlet end using these methods. Servlet get parameter, get parameter values, get content length. So these methods help us what type of data has been sent from HTML. So when an HTML page is sending a data, that data is received using these methods. So basically it has a signature string return type get parameter is a method name and string name is an input parameter. So this is how method is read. This is a signature of get parameter public. It is public. These are all methods are public string is a return type get parameter is a method name and input parameter is a string name. So it is going to accept string name. So this is how get parameter helps us to collect data that is passed from HTML. HTML also needs to pass the data in a specific format. So we will see to it. Now let us take a demonstration directly without wasting a time. I'll come down to eclipse. This is what eclipse previously we were doing in the last video demo Servlet we have done in the previous video, right? So here continuing what has to be done if I maximize this you can see here we had written this do get method inside do get method we had written response dot get content type response dot get this thing print writer we have used to display welcome to the first sublet, right? So continuing with that I have I've deleted that particular code. I'll write a fresh code over here. We will see to it. Then if I come back over here what has to be done if you remember the root structure what is the root structure at the web directory of Servlet. If I want to write any HTML pages HTML pages will reside directly inside root folder. Now what is root folder here web content is a root folder over here. So if I want to write any HTML pages I will right click over here new. I'll take an HTML page. Okay I'll make it here index dot HTML index dot HTML page. Okay. Now I'll finish it. Now one index file index dot HTML file will be created. I'll delete this because this is a by default code which comes as a default page of HTML. Instead of this, let us write some code. This code is required. You can just note it down. So I'll paste this code over here. What is this code form action action is welcome over here method is get enter your name. So it is just a form I'm creating a form over here to enter the name. So when a user enters a name that name has to be passed to Servlet. So Servlet has to receive this name. Okay. So input type is text text is our type and name is this is a key for that name. So what name we are passing this name should be unique then input type is submit. So submit button will come. So this is a general form in HTML. I don't go into detail of it. So once you write this HTML code, okay, now we need to go back to demo sublet when I when a user clicks on submit this data has to be passed to demo sublet. Okay. So what demo sublet has to do demo sublet has to accept this particular form the data from that form. Right. For that, I have a code over here. Let us take this code and I'll paste it over here. So here it is the same thing which we have done in the last video response dot set content type your set content type is HTML print writer here again it should be response dot print get writer it was used for writing a purpose and your important thing is request dot get parameter what request dot get parameter is going to do it is accepting name if you remember here we are passing name this keyword is matched over here get parameter is going to take that name and return its value that that value whatever you are going to type in the text will be passed inside this particular string name. Okay. Then what I'm doing just to make sure that okay I've received the correct data I'm printing pw dot print write this print Ellen welcome that particular name. Okay. It makes sense. I think after that you have to close it close the connection. Okay. Now this is what we have done in index dot HTML file. So how to execute it we have already seen how to execute this particular file. So index dot HTML is residing inside web content. So now come down to test 151 right click run as run on server save the changes finish it should execute now. So let us add it. Okay. This is the form which we have created enter your name I'll enter my name as Ankit. So enter your name Ankit login it will show an error it is showing an error because here it is going if you see your detail it is going to welcome page but we don't have any welcome sublet over here. So what changes has to be done come down to index dot HTML file and make a change over here action is not welcome action here is demo sublet it should go to demo sublet page save this. Okay. Then let us stop the server we have stopped the server now server has stopped now again we have made the changes now again go to test HTML and run it run as run on server the form is again displayed here I'll write now Ankit and click on login. Now it is showing welcome Ankit. So have you understood now what changes has to be done. We'll come back to our presentation. So here this we have seen now this is a simple question for you people with servlet request method is used in the program try to answer it we have just now seen it. The answer is get parameter get parameter is an important method to retrieve data from HTML page. Okay. Now here same thing if I come down to eclipse if I come down to eclipse if I want to make this I want to change this name Ankit to something else I'll stop this or we'll come back and try to make some other name let's say Ram login. So welcome Ram. So this is how it is working understood. So in index dot HTML page we have what we have written action is demo sublet method is get. So this method is important when you're writing get it is going to do get method. So this all data inside it will call to do get because I'm using a method type as get. Okay. And what we have done in demo sublet in demo sublet we are using this request dot get parameter name this if I change something over here if I make it and name equal to and in demo sublet get parameter it should be and not name this both things should be seen this is very important to understand once understand that it is very easy. So this name and demo sublet it should be seen. Okay. Now these are some of the references which have used you can go back and study with it you can practice more you can make some changes let it have some error no issues but practice makes you perfect. Okay. Thank you.