 First of all I welcome you all to IATB, just already I said that JSP is a Java server page. So, what is the main thing for using a JSP is that suppose to create a dynamic with HTML itself we can create a web page, but the limitation is that we cannot have dynamic content. However, the content you have posted in HTML it will be static, if you want to dynamically change the content, if you want to update some datas, so we have to use server page. So, now we are using a JSP, then what is actually the JSP is there, it is a mixing of HTML as well as Java. We have a object oriented programming Java, how to post those code in a web, web application. So, that is why we are going for JSP, then if you want to post the Java code in JSP page we have to use a special tag, with help of this tag we can directly use our Java code inside the JSP page, then the obviously the page supposed to be extension with .JSP, then ok. In JSP when you are running the JSP page it is not directly compile as a JSP page, what is happening, just I will show you the environment of JSP, we have a JSP page when your browser request for any JSP page what is happening, the two thing is happening over there, if the page JSP page does not have any Java code, it is like a ordinary HTML, so it is a static content, it is directly goes to the browser again, it is going to response to the browser, if the page have a dynamic content, if there is a Java code, it will goes to the Java translator, then it will be translate to servlet, what is the servlet, it is a Java class with the main feature of request and response of the particular client or server, so that is a feature of servlet, so what will happen the JSP page will be convert into servlet, again the servlet will be is a ordinary Java, we can compile that one as a class file, then we can post the data into the browser, ok, this is the environment of JSP, ok, then already I said that if you want to directly post the Java code in your JSP, we have to use the special tag, we have a three special tag to use our Java code, the first one is a expression, expression we knows, if you want to simply assign the variable, we want to use the simple variables to your JSP page, we can use the first one, then we have to use the percentage equal, then when you go for code, if you want to use the direct code, for example if you want to use the conditional statement or for loop, while loop, if you want to use any the feature of Java, directly we have to use only the percentage, directly we can use the code, then the third one, the second one that is we can call it as a scriptlet, the third one is a declaration, what is a declaration, so if you want to use the any variable you want to declare the globally, we can use, in second part we have the code part, in code part itself we can able to declare the variable, the difference over there, the first one whatever the you are declare in a code, it is a local, if you want to declare any variable as a global one, we have to use declaration, that is a percentage, sorry percentage explanation, sorry, then not only variable we can use the method in declaration part, simply we can declare a method, the further we can invoke the particular method for our code, this is a Java tags, I will show you the example, the code green color, now it is a simple html, I have displayed the current date, already you knows what is that, Java it will dot date, what it will do, it is a one predefined method available in Java, comes under utility package, so I am directly using that, so what I am doing, the value whatever it is taking as a date, it will be assigned to the page, so I am using a, what I am using now, which tag, expression, so it is an variable assignment, so I am using a expression, then if for in ordinary Java, what we will do, if you want to use any predefined methods, comes under any packages, what you will do, we have to impose those package, then we have to use directly the method, this is the way we are using in Java, why not we are using here, we can use, we have some other tag like import the packages, so let me discuss this in future slides, by the way I like to give a demo for each and every code, it is ok for you, but the code I already have implemented here, just simply I will show, then I will explain, then I will run, the same code, we have written, simply we are using the predefined method of Java, if we are running this one, what will happen, simply it will be display the content, then the current date, now we are going to see the second JSP tag, that is the scriptlet, in a scriptlet, when you are using a scriptlet, we can use the scriptlet as a direct Java code, we can insert in your JSP page. So, not only directly for, there is no restriction for using the sequence of Java and HTML code, we can mix both of them, here just look at this code, what I am doing, just simply I am using a if-else statement, but in between if-else statement I am using a, what I am using, sorry in this one I am directly using a the Java, I am not using a mixing of HTML as well as the Java, but there is no restriction for using mixing of JSP as well as Java code. So, what actually this code will do, I am using a random method, what will do, random method will generate the some random value, the floating random value, it will display less than 1. So, I am checking whether the value is less than 0.5, it will display, have a nice day else, it will display, have a good day. I am replacing this page, what will happen, it is a random. So, sometime it will be same, sometime it will be deeper based on the random value, here what I am doing, simply I have used the direct Java code into your JSP page. I try to use mixing of HTML and HTML tag as well as Java code, how it is possible, I will make I will do some changes with this code, you came to know how to how we can mix both of the things. The first line, it is a Java code. So, I have added that line in a script plate, the second line I am going to use instead of this, I am going to use a ordinary HTML, H1, then it is a HTML there is no need for adding this line in a script plate, you go for third line, what is the third line, it is belongs to Java. So, we have to add this code in a script plate, then the fourth line is belongs to Java, you have any problem with understanding of this lines, no, no. So, now what I have done previously I have used the only Java code, but here I have mixed both Java and HTML. So, it is possible. So, now I am same page I am running over here that is a script plate. So, script plate simply we can have a, we can add the Java code in our JSP page. Now, there is no restriction for the sequence of using Java code as well as HTML code. So, what is the next one, declaration. So, declaration, if you want to declare any variable we can declare using the declaration tag. The declaration the main thing is that it is a whatever you are declare we can use that particular variable entire in entire pages, there is a global one. I have declared a one global variable that is a integer that is a access count. So, simply I am going to just display the visiting visitors count, how many times the visitor is visiting the particular web page. If the for initially we have globally declared that and we have initialized the value as 0. When the visitors visiting a first time it shows you are welcome to, you are welcome to our website. Else if the already the visitor is visited. So, it will give the information you have visited this much time. First time I am visiting this page and I am refreshed. So, it is goes to the second time. So, likewise the count will be increment. When it will be goes to the first state when you are restart your server. So, it mean that all your data. So, where the particular data will be there the global declaration everything will be where it will be in your system memories like cookies those kind of catch. So, if you when you are restarting your server. So, what will happen all the data will be the resetted again it will goes to starting stage. So, when you are restart your server it will goes to the initial stage. Next one is the JSP comment. What is a comment? What is the need of using comment? For developer purpose they want to give some explanation about your own code that is a comment. We can use comment in HTML we already we can use comment. What is the way we can use the comment? The first one. If you are mention your comment in the explanation the read with the HTML if I will show you the difference between how way of using HTML comment as well as JSP comment. If you are using a HTML comment the comment will be shown in your browser whether it will show in browser source code. So, in HTML or all the web pages we can see the source code. So, when you are look at the source code of the particular page what of the HTML comment you have mentioned it will be display in your source code. If you are mention in JSP comment it will not visible. I have in this page itself we have two comments. The first line. Hi this is JSP comment comments. The second one I have written some code over here. So, there is a two comments I have used in the same page. Just go to the page if you go to the page source what is happening we can able to use the HTML comment. So, that is the difference between HTML comment and JSP comment. When you want to the comment supposed to be not visible to the client we have to use JSP comment. Next one is the directory. I said that if you want to use directly the predefined method we have to import the package. If you want to import any packages we have to use directives. Directives we can add the predefined packages then under this package whatever the method you have we can directly use it in your page. It is a way of using directives. Simply that we have to add at then page we have to mention a key word is page then another attribute is that imports then we have to mention a particular package within a double codes. The first one is directives is going to import your package. In this this one also comes under directives, but this one include your web page or your already you have developed any pages. For example, what we will do we have developing a 10 or 15 number of pages for a particular website. All the website we want to use the same header. What we have to do? What we have to do? Yeah, simply the header file we have to create separately the header file supposed to include in all the pages. No need to recreate the particular tags again and again. So, that is the feature of using includes. The header file I have used. In this header file there is a content Indian Institute of Technology Bombay then summer internship 2012. For example, when I am running this page what will happen? It will display the particular header information. I want to use the same template in all the page header. So, simply we have to include this tag over your necessary pages. For example, I have used scriptlet. In scriptlet I want to add. What I have done? Simply I have added the header files in your scriptlet jsp. When I am running this page previously what was displayed? I have a nice tag. Now it is displayed with headers. There is a feature of using include include. That is the action tag. So, what are the features we have in the includes the directives? The same feature we can have in another format that is called action tags. For if you want to include the same page we can use in action tag also. The action tag it is a start with jsp colon. What is the action going to perform? For example, if you want to include the same format jsp colon includes the page which one you want to include as a header you want to include here. The same way if you want to the redirect the page to some other page. So, for that we have another action tag that is called forward. Simply we have to mention a jsp colon forward the where you want to forward. That is the action tag. Then if you want to use that is a another features like if you want in action tag itself we want to add the we can pass the parameter. What is the parameter? For example, I am just I am transferring my URL to some other for example with Google. At the time of transferring to Google I want to pass some parameter for searching the particular keyword. So, we can able to pass those parameter with values. So, for that we have to use jsp param action. Inside that we want to add this tag jsp param. We have to mention two things one is the name another one is the value. So, for example, if you want to Google search directly we want to go to the particular search page what we have to do? Simply we have to go for Google.co.in goes in more than search equal to particular keyword. If you are giving like this what will happen? Directly the what the value have mention it will goes to the particular search result page. So, likewise we can forward as a resulting page x 1 is a jsp the implicit objects we have lot of implicit object in jsp. The jsp page by default we have a request response already it is added in your jsp. So, with the help of the request response we have lot of the implicit objects are there. The first one is a request what is the request? When the client requesting any data. So, that is a request for example, if you have one page for example, you take it as a Google. So, what will happen? In the home page of Google we have a search text box is there. If you are enter any data you are pressing the button search what will happen? The data whatever your search in a search text box it will goes to the another page that value that is called as a request parameter. What is the response? Another one is a response. When you want to send back the result for the particular request we can use response parameter. Another one is a session whether we need to use session where we are using session? Validate logout to go for any email services gmail yahoo what will happen? When you are login we can view the mail list inbox send items everything. When you are pressing a logout whether it is possible to again you go to the same page without login no it is not possible. So, it mean that your session is destroyed it is a expired. So, like this when you want to maintain a session we have to use session objects. Another one is a fourth one is a out. So, out is like a print statement when you want to print the particular statement in your browser we can use out. Then application anybody heard about application object? That is an application object is there. The application object there is a facility to have the particular attributes over all the pages. Like how we are using in a session I will give you the difference of session and application. The session if you are set for example, if you are login. For example, you have login as a name first name and password. For the particular first name your password or value will be set and then the based on your username session will be created. The particular session will be valid for the particular user. So, the particular value the session value is only available for limitations of users, but application variable it is not like that. It will be common for all the user whatever the value it is available application object we can anyone can use that object. That is when you want to use all the pages for the particular value we can use application objects. Then exception here JSP page itself we can have an exception information. For example, if you are searching any pages the page is not found. So, you want to transmit or you want to give some information belongs to the particular exception. We can use exception object to show the information of the particular exception. This is the implicit objects. I have given us some sample examples. For if you take this as a request what is a request when you are clients giving any passing parameter to another page that data is considered as a requesting parameter. The first one what I have done in a anyone knows the action tag what is the action tag sorry anchor tag. It will redirect to some other URL or some other location that is the anchor tag. In anchor tag I have mentioned one file JSP file with some parameter with values. When you are pressing the particular link what will happen the data also going to pause. So, we can retrieve that parameters as a query string. So, the request of request object we can get the query string. Then another one if you have a text field if you have a form in your HTML page or JSP page we have a form inside the form if you have a text field. If you want to when you are submitting the button the form data will be sent to your next page. So, at the time if you want to take the particular text field value we can get as a with help of request sorry sorry request. Request dot get sorry yeah get parameter. We have to mention a name of the particular text box another one is the response like how we have action tag we have used forward what is the forward. So, it will redirect your page to some other page likewise we have a response parameter with help of response object we can also redirect to the particular page with help of the method send redirect we have to mention a URL or particular page. Then we have a set header for example, if you just you may seen the particular website there will be catch a what is a catch a it will be temporary storage of the particular page the page data will be stored. For example, if you are login in a Gmail your name is entered then your password is entered after the second day you are going to the same page if you are typing the name the name will be available in your text box that is a auto field. So, how it is coming the data what you are entered previously it is available in catch a when you want to fill the particular data supposed to they are not supposed to save in your catch a we have to restrict the catch a for example, if you for some secured website if you go for s b i that is no need to save the catch a. So, this kind of some restriction we can use avoiding storing of catch a. Then we can set the context type the what is the particular page context we can set whether it is an PDF or whether it is an HTML or it is a document. So, we can set the context session when you developing the web based application definitely you must have the session we have to manage the session that is a very important thing. There is a for the four way we can manage the session the first one is a session objects. There is a predefined objects are available in your j s p there is a session with the help of that we can set the attribute we can get the attributes and then we can make the make the particular thing destroy like with the second one is a cookies what is a cookies like it will be temporarily stored in your browser or your the vendor system it will not available in your server or somewhere it will be available in your own system that is a cookies then hidden fields what is a hidden fields the particular for example, if you want to at the time of sending data through form we can have the particular field as hidden it will not visible in visible to the user, but we can have some data in that field we can transmit to another page that is a hidden and then is a URL rewriting what is a URL you are writing we can pass the data in URL that is a URL rewriting. For example, I have given a session.jsp sorry session I am using session in j s p how to set the session attributes we have already I said that we have a already we have session that is the objects with the help of that object we can set the particular attributes we have we have two parameters one is the name of the session another one is the value of the session the set how do you the set is that like sorry session dot set attributes we have to pass two values one is the first one is the name of the session another one is the value we are going to pass for the particular name here what I have set set dot set attributes s c s d a l I have passed the value what is that value request dot get parameter the value which is passed from a previous page next how to use the session variable with help of the name we can get it in anywhere for example session dot get attributes we have to pass the name of the session then for removing your session we have to use remove attribute attribute name you have to mention the application object we can use the application object is already exist in your all j s p page with help of that we can set the attribute as it is how you are setting in your session but the main difference session and application application is comma for all the pages all the pages all the users you go for session it will be restricted for the particular session user or particular session you may get more information about j s p that is it about a j s p ok.