Difference between revisions of "Java-Business-Application/C2/Servlet-Methods/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 4: Line 4:
  
 
|-
 
|-
| 00.01
+
| 00:01
 
| Welcome to the spoken-tutorial on  '''Servlet Methods.'''
 
| Welcome to the spoken-tutorial on  '''Servlet Methods.'''
  
 
|-
 
|-
|00.06
+
|00:06
 
| In this tutorial we will learn to
 
| In this tutorial we will learn to
  
 
|-
 
|-
| 00.08
+
| 00:08
 
| create a '''simple login form''' using '''JSP'''
 
| create a '''simple login form''' using '''JSP'''
  
 
|-
 
|-
| 00.13
+
| 00:13
 
| Pass parameters using '''doGet''' '''method'''
 
| Pass parameters using '''doGet''' '''method'''
  
 
|-
 
|-
| 00.16
+
| 00:16
 
| Pass parameters using '''doPost method'''
 
| Pass parameters using '''doPost method'''
  
 
|-
 
|-
| 00.20
+
| 00:20
 
| Difference between '''doGet '''and '''doPost''' methods
 
| Difference between '''doGet '''and '''doPost''' methods
  
 
|-
 
|-
|00.25
+
|00:25
 
|Here we are using
 
|Here we are using
  
 
|-
 
|-
| 00.26
+
| 00:26
 
| '''Ubuntu Version''' 12.04
 
| '''Ubuntu Version''' 12.04
  
 
|-
 
|-
| 00.30
+
| 00:30
 
| '''Netbeans IDE''' 7.3
 
| '''Netbeans IDE''' 7.3
  
 
|-
 
|-
| 00.33
+
| 00:33
 
| '''JDK''' 1.7
 
| '''JDK''' 1.7
  
 
|-
 
|-
| 00.36
+
| 00:36
 
| '''Firefox''' web-browser 21.0
 
| '''Firefox''' web-browser 21.0
  
 
|-
 
|-
| 00.39
+
| 00:39
 
|You can use any web-browser of your choice.
 
|You can use any web-browser of your choice.
  
 
|-
 
|-
| 00.43
+
| 00:43
 
| To follow this tutorial you must know  
 
| To follow this tutorial you must know  
  
 
|-
 
|-
| 00.46
+
| 00:46
 
| Core Java using '''Netbeans IDE'''  
 
| Core Java using '''Netbeans IDE'''  
  
 
|-
 
|-
| 00.49
+
| 00:49
 
| '''HTML'''
 
| '''HTML'''
  
 
|-
 
|-
| 00.51
+
| 00:51
 
| Basics of '''Java Servlets '''and '''JSPs'''
 
| Basics of '''Java Servlets '''and '''JSPs'''
  
 
|-
 
|-
| 00.56
+
| 00:56
 
|If not, for relevant tutorials please visit our website.
 
|If not, for relevant tutorials please visit our website.
  
 
|-
 
|-
| 01.00
+
| 01:00
 
| We will begin by creating our web application- the '''Library Management System.'''
 
| We will begin by creating our web application- the '''Library Management System.'''
  
 
|-
 
|-
| 01.06
+
| 01:06
 
|First, we will create the '''home page.'''
 
|First, we will create the '''home page.'''
  
 
|-
 
|-
| 01.09
+
| 01:09
 
|The '''home page''' will contain a simple '''login form'''.
 
|The '''home page''' will contain a simple '''login form'''.
  
 
|-
 
|-
| 01.14
+
| 01:14
 
|It will allow authenticated users to login to the '''Library Management System.'''
 
|It will allow authenticated users to login to the '''Library Management System.'''
  
 
|-
 
|-
| 01.20
+
| 01:20
 
| Now, let us switch to '''Netbeans IDE.'''
 
| Now, let us switch to '''Netbeans IDE.'''
  
 
|-
 
|-
| 01.23
+
| 01:23
 
| Let us go to the '''index ''' '''dot''' '''jsp''' page, that we had already modified earlier.
 
| Let us go to the '''index ''' '''dot''' '''jsp''' page, that we had already modified earlier.
  
 
|-
 
|-
| 01.30
+
| 01:30
 
| I have modified this page to create our '''home page.'''
 
| I have modified this page to create our '''home page.'''
  
 
|-
 
|-
| 01.35
+
| 01:35
 
| We keep the '''title '''as '''Home Page.'''
 
| We keep the '''title '''as '''Home Page.'''
  
 
|-
 
|-
| 01.38
+
| 01:38
 
| Inside the body, we have a '''table,'''with '''border '''''equal to '''''1.'''
 
| Inside the body, we have a '''table,'''with '''border '''''equal to '''''1.'''
  
 
|-
 
|-
| 01.44
+
| 01:44
 
|You can have a look at the code here.
 
|You can have a look at the code here.
  
 
|-
 
|-
| 01.47
+
| 01:47
 
| Inside the '''table''' we have included a heading, '''Welcome to Library Management System.'''
 
| Inside the '''table''' we have included a heading, '''Welcome to Library Management System.'''
  
 
|-
 
|-
| 01.54
+
| 01:54
 
| Next, we have '''paragraph tag''' that includes, '''This is the home page for Library Management System.'''
 
| Next, we have '''paragraph tag''' that includes, '''This is the home page for Library Management System.'''
  
 
|-
 
|-
| 02.03
+
| 02:03
 
| Then, we have a '''hyperlink,''' which links to a page called '''visitorHomePage ''' '''dot ''' '''jsp.'''
 
| Then, we have a '''hyperlink,''' which links to a page called '''visitorHomePage ''' '''dot ''' '''jsp.'''
  
 
|-
 
|-
| 02.11
+
| 02:11
 
| We will create this page later.
 
| We will create this page later.
  
 
|-
 
|-
| 02.13
+
| 02:13
 
| Next,we have a very simple '''login form.'''
 
| Next,we have a very simple '''login form.'''
  
 
|-
 
|-
| 02.18
+
| 02:18
 
|This form allows a '''registered user''' to '''login''' .
 
|This form allows a '''registered user''' to '''login''' .
  
 
|-
 
|-
| 02.22
+
| 02:22
 
| Before creating the '''form ''' you will have to create a '''servlet '''named '''GreetingServlet.'''
 
| Before creating the '''form ''' you will have to create a '''servlet '''named '''GreetingServlet.'''
  
 
|-
 
|-
| 02.28
+
| 02:28
 
| Pause the tutorial and create a new '''servlet''' as explained in the earlier tutorial.  
 
| Pause the tutorial and create a new '''servlet''' as explained in the earlier tutorial.  
  
 
|-
 
|-
| 02.35
+
| 02:35
 
| Note that the '''servlet name''' is '''GreetingServlet.'''
 
| Note that the '''servlet name''' is '''GreetingServlet.'''
  
 
|-
 
|-
| 02.39
+
| 02:39
 
|The '''URL pattern''' should be '''GreetingServletPath.'''
 
|The '''URL pattern''' should be '''GreetingServletPath.'''
  
 
|-
 
|-
| 02.44
+
| 02:44
 
| This''' form''' has two input elements - '''Username and Password.'''
 
| This''' form''' has two input elements - '''Username and Password.'''
  
 
|-
 
|-
| 02.50
+
| 02:50
 
|It also has a '''Submit button''' that says '''Sign In.'''
 
|It also has a '''Submit button''' that says '''Sign In.'''
  
 
|-
 
|-
| 02.55
+
| 02:55
 
| Next, we have a '''paragraph tag''' that includes a link to '''addUser.jsp.'''
 
| Next, we have a '''paragraph tag''' that includes a link to '''addUser.jsp.'''
  
 
|-
 
|-
| 03.03
+
| 03:03
 
|This is the '''registration page''' for those '''users''' who have not yet registered.
 
|This is the '''registration page''' for those '''users''' who have not yet registered.
  
 
|-
 
|-
| 03.09
+
| 03:09
 
| Now, let us go to our '''GreetingServlet.java. '''
 
| Now, let us go to our '''GreetingServlet.java. '''
  
 
|-
 
|-
| 03.14
+
| 03:14
 
| Note that '''GreetingServlet.java''' is created in the same package '''org.spokentutorial.'''
 
| Note that '''GreetingServlet.java''' is created in the same package '''org.spokentutorial.'''
  
 
|-
 
|-
| 03.23
+
| 03:23
 
| Now, this '''servlet '''will be able to access the '''form data '''from the '''request object.'''
 
| Now, this '''servlet '''will be able to access the '''form data '''from the '''request object.'''
  
 
|-
 
|-
| 03.30
+
| 03:30
 
| This '''servlet '''will act as a '''controller.'''
 
| This '''servlet '''will act as a '''controller.'''
 
  
 
|-
 
|-
| 03.33
+
| 03:33
 
|Do you recall that we had come across '''controller''' earlier?
 
|Do you recall that we had come across '''controller''' earlier?
  
 
|-
 
|-
| 03.38
+
| 03:38
 
| Now, we will see what the '''servlet '''does as a '''controller.'''
 
| Now, we will see what the '''servlet '''does as a '''controller.'''
  
 
|-
 
|-
| 03.42
+
| 03:42
 
|The '''form data''' will reside in the '''request object.'''
 
|The '''form data''' will reside in the '''request object.'''
  
  
 
|-
 
|-
| 03.46
+
| 03:46
 
|The first task is to retrieve the '''form''' data parameters.
 
|The first task is to retrieve the '''form''' data parameters.
  
 
|-
 
|-
| 03.51
+
| 03:51
 
|This is done using the '''getParameter method '''on the '''request object.'''
 
|This is done using the '''getParameter method '''on the '''request object.'''
  
 
|-
 
|-
| 03.57
+
| 03:57
 
| So, let us switch to '''Netbeans IDE.'''
 
| So, let us switch to '''Netbeans IDE.'''
  
 
|-
 
|-
| 04.02
+
| 04:02
 
| Type inside the''' doGet method,'''  
 
| Type inside the''' doGet method,'''  
  
 
|-
 
|-
| 04.04
+
| 04:04
 
|'''PrintWriter space out equal to response dot getWriter.'''''
 
|'''PrintWriter space out equal to response dot getWriter.'''''
  
 
|-
 
|-
| 04.14
+
| 04:14
 
| Next, we will retrieve the '''form data '''parameters.
 
| Next, we will retrieve the '''form data '''parameters.
  
 
|-
 
|-
| 04.18
+
| 04:18
 
| So that on the next line type,  
 
| So that on the next line type,  
  
 
|-
 
|-
| 04.20
+
| 04:20
 
| '''String''' space '''username''' equal to '''request'''  dot '''getParameter ''' within brackets and double quotes '''userName''''''semicolon'''.
 
| '''String''' space '''username''' equal to '''request'''  dot '''getParameter ''' within brackets and double quotes '''userName''''''semicolon'''.
  
 
|-
 
|-
| 04.35
+
| 04:35
 
|Note that this '''userName '''is the name we have included in the '''form tag '''for '''User Name.'''
 
|Note that this '''userName '''is the name we have included in the '''form tag '''for '''User Name.'''
  
 
|-
 
|-
| 04.43
+
| 04:43
 
| Similarly, we will retrieve the '''password''' also.
 
| Similarly, we will retrieve the '''password''' also.
  
 
|-
 
|-
| 04.48
+
| 04:48
 
|So on the next line, type, '''String ''' space '''password''' equal to '''request''' dot '''getParameter ''' within brackets and double quotes '''password''' semicolon.
 
|So on the next line, type, '''String ''' space '''password''' equal to '''request''' dot '''getParameter ''' within brackets and double quotes '''password''' semicolon.
  
 
|-
 
|-
| 05.03
+
| 05:03
 
| Next, we will print the '''User Name '''in the '''output'''.
 
| Next, we will print the '''User Name '''in the '''output'''.
  
 
|-
 
|-
| 05.08
+
| 05:08
 
| So, on the next line type  
 
| So, on the next line type  
  
 
|-
 
|-
| 05.10
+
| 05:10
 
|'''out ''dot '''println''' within brackets and double quotes ''' Hello from GET Method plus username.'''
 
|'''out ''dot '''println''' within brackets and double quotes ''' Hello from GET Method plus username.'''
  
 
|-
 
|-
|05.21
+
|05:21
 
| Now, to run this project, right-click on '''MyFirstProject. '''
 
| Now, to run this project, right-click on '''MyFirstProject. '''
  
 
|-
 
|-
| 05.27
+
| 05:27
 
| Click on '''Clean and Build.'''
 
| Click on '''Clean and Build.'''
  
 
|-
 
|-
| 05.29
+
| 05:29
 
| Again right click on '''MyFirstProject ''',  click on '''Run.'''
 
| Again right click on '''MyFirstProject ''',  click on '''Run.'''
  
 
|-
 
|-
| 05.35
+
| 05:35
 
| So, the '''server '''is up and running.
 
| So, the '''server '''is up and running.
  
 
|-
 
|-
| 05.38
+
| 05:38
 
|It has deployed '''MyFirstProject.'''
 
|It has deployed '''MyFirstProject.'''
  
 
|-
 
|-
| 05.41
+
| 05:41
 
|We have got our '''home page '''displayed in the '''browser'''.
 
|We have got our '''home page '''displayed in the '''browser'''.
  
 
|-
 
|-
| 05.45
+
| 05:45
 
| Observe that the '''title '''of the page is '''Home Page.'''
 
| Observe that the '''title '''of the page is '''Home Page.'''
  
 
|-
 
|-
| 05.50
+
| 05:50
 
| We can see a very simple '''login form''' here.
 
| We can see a very simple '''login form''' here.
  
 
|-
 
|-
| 05.54
+
| 05:54
 
| Let me enter the '''Username '''and '''Password.'''
 
| Let me enter the '''Username '''and '''Password.'''
  
 
|-
 
|-
| 05.58
+
| 05:58
 
| I will type '''arya '''as the '''Username.'''
 
| I will type '''arya '''as the '''Username.'''
  
 
|-
 
|-
| 06.02
+
| 06:02
 
| And '''arya*123 '''as the '''Password.'''
 
| And '''arya*123 '''as the '''Password.'''
  
Line 302: Line 301:
  
 
|-
 
|-
| 06.09
+
| 06:09
 
| We can see that we have got the output '''Hello from GET Method''' '''arya'''.
 
| We can see that we have got the output '''Hello from GET Method''' '''arya'''.
  
 
|-
 
|-
| 06.15
+
| 06:15
 
| Now, the '''user '''was able to login here because we have not included any validation inside the code.  
 
| Now, the '''user '''was able to login here because we have not included any validation inside the code.  
  
 
|-
 
|-
| 06.24
+
| 06:24
 
| We will do this in the later tutorial.  
 
| We will do this in the later tutorial.  
  
 
|-
 
|-
| 06.28
+
| 06:28
 
| Now, have a look at the '''URL '''here.
 
| Now, have a look at the '''URL '''here.
  
 
|-
 
|-
| 06.31
+
| 06:31
 
|It is '''localhost '''''colon '''''8080 '''''slash '''''MyFirstProject '''''slash '''''GreetingServletPath '''''question mark '''''userName '''''equal to '''''arya and password '''''equal to '''''arya *123.
 
|It is '''localhost '''''colon '''''8080 '''''slash '''''MyFirstProject '''''slash '''''GreetingServletPath '''''question mark '''''userName '''''equal to '''''arya and password '''''equal to '''''arya *123.
  
 
|-
 
|-
| 06.49
+
| 06:49
 
|Now, '''form data '''is separated from the page information by a '''question mark.'''
 
|Now, '''form data '''is separated from the page information by a '''question mark.'''
  
 
|-
 
|-
|06.56
+
|06:56
 
| We can see that '''username '''and '''password '''that we had entered in the form is inside the URL also.
 
| We can see that '''username '''and '''password '''that we had entered in the form is inside the URL also.
  
 
|-
 
|-
| 07.05
+
| 07:05
 
| Now, let us try to do the same using '''POST Method.'''
 
| Now, let us try to do the same using '''POST Method.'''
  
 
|-
 
|-
| 07.10
+
| 07:10
 
| So, switch back to the '''IDE.'''
 
| So, switch back to the '''IDE.'''
  
 
|-
 
|-
| 07.12
+
| 07:12
 
| Copy the code we had written for  '''doGet Method '''and paste in the '''doPost Method.'''
 
| Copy the code we had written for  '''doGet Method '''and paste in the '''doPost Method.'''
  
 
|-
 
|-
| 07.20
+
| 07:20
 
| Now, change the '''println''' statement to '''Hello from POST Method.'''
 
| Now, change the '''println''' statement to '''Hello from POST Method.'''
  
 
|-
 
|-
|07.27
+
|07:27
 
| Now, let us open '''index''' dot '''jsp.'''
 
| Now, let us open '''index''' dot '''jsp.'''
  
 
|-
 
|-
| 07.31
+
| 07:31
 
| Here, we must change the '''method attribute '''of the '''form tag '''to '''POST.'''
 
| Here, we must change the '''method attribute '''of the '''form tag '''to '''POST.'''
  
 
|-
 
|-
| 07.37
+
| 07:37
 
|You can have a look at this code now.
 
|You can have a look at this code now.
  
 
|-
 
|-
| 07.42
+
| 07:42
 
|We have '''form action '''''equal to '''''GreetingServletPath method '''''equal to '''''POST.'''
 
|We have '''form action '''''equal to '''''GreetingServletPath method '''''equal to '''''POST.'''
  
 
|-
 
|-
| 07.49
+
| 07:49
 
| Now, we will run this Project again
 
| Now, we will run this Project again
  
 
|-
 
|-
| 07.53
+
| 07:53
 
| So, Right click on '''MyFirstProject '''and click on '''Run'''
 
| So, Right click on '''MyFirstProject '''and click on '''Run'''
  
 
|-
 
|-
| 07.58
+
| 07:58
 
| We have got an output similar to the one we got, when we used the '''GET method.'''
 
| We have got an output similar to the one we got, when we used the '''GET method.'''
  
 
|-
 
|-
| 08.04
+
| 08:04
 
| So let us type  '''User Name '''and '''Password '''again.
 
| So let us type  '''User Name '''and '''Password '''again.
  
 
|-
 
|-
| 08.08
+
| 08:08
 
| Then click on '''Sign In.'''
 
| Then click on '''Sign In.'''
  
 
|-
 
|-
| 08.12
+
| 08:12
 
| Note that we have got '''Hello from POST Method arya.'''
 
| Note that we have got '''Hello from POST Method arya.'''
  
 
|-
 
|-
| 08.17
+
| 08:17
 
| Now, take a look at the '''URL.'''
 
| Now, take a look at the '''URL.'''
  
 
|-
 
|-
| 08.19
+
| 08:19
 
|It is '''localhost '''''colon '''''8080 '''''slash '''''MyFirstProject '''''slash '''''GreetingServletPath '''
 
|It is '''localhost '''''colon '''''8080 '''''slash '''''MyFirstProject '''''slash '''''GreetingServletPath '''
  
 
|-
 
|-
| 08.25
+
| 08:25
 
| Here we do not see the '''form data '''in the '''URL '''of the '''request.'''
 
| Here we do not see the '''form data '''in the '''URL '''of the '''request.'''
  
 
|-
 
|-
| 08.30
+
| 08:30
 
| This is the major difference between '''doGet '''and '''doPost Methods.'''
 
| This is the major difference between '''doGet '''and '''doPost Methods.'''
  
 
|-
 
|-
| 08.35
+
| 08:35
 
| Now, let us learn when to use '''GET '''and when to use '''POST Methods.'''
 
| Now, let us learn when to use '''GET '''and when to use '''POST Methods.'''
  
 
|-
 
|-
| 08.42
+
| 08:42
 
|'''GET Method '''is used when:
 
|'''GET Method '''is used when:
  
 
|-
 
|-
| 08.44
+
| 08:44
 
| the '''form '''is small and hence the '''data '''is less.
 
| the '''form '''is small and hence the '''data '''is less.
  
 
|-
 
|-
| 08.48
+
| 08:48
 
| the '''user''' wants the contents of the data to be visible in the '''URL.'''
 
| the '''user''' wants the contents of the data to be visible in the '''URL.'''
  
 
|-
 
|-
| 08.53
+
| 08:53
 
|'''POST Method '''is used when:
 
|'''POST Method '''is used when:
  
 
|-
 
|-
| 08.55
+
| 08:55
 
| the '''form '''is large and hence the '''data '''is more.
 
| the '''form '''is large and hence the '''data '''is more.
  
 
|-
 
|-
| 09.00
+
| 09:00
 
| the '''user''' does not want the contents of the data to be visible in the '''URL.'''
 
| the '''user''' does not want the contents of the data to be visible in the '''URL.'''
  
 
|-
 
|-
| 09.06
+
| 09:06
 
|ex: '''passwords'''
 
|ex: '''passwords'''
  
 
|-
 
|-
| 09.08
+
| 09:08
 
| Let us summarize.
 
| Let us summarize.
  
 
|-
 
|-
| 09.10
+
| 09:10
 
|In this tutorial we have learnt to:
 
|In this tutorial we have learnt to:
  
 
|-
 
|-
| 09.12
+
| 09:12
 
| create a simple login form using '''JSP'''
 
| create a simple login form using '''JSP'''
  
 
|-
 
|-
| 09.16
+
| 09:16
 
| Pass parameters using '''doGet''' '''method'''
 
| Pass parameters using '''doGet''' '''method'''
  
 
|-
 
|-
| 09.19
+
| 09:19
 
| Pass parameters using '''doPost method'''
 
| Pass parameters using '''doPost method'''
  
 
|-
 
|-
| 09.22
+
| 09:22
 
| Difference between''' doGet '''and '''doPost''' methods
 
| Difference between''' doGet '''and '''doPost''' methods
  
 
|-
 
|-
| 09.26
+
| 09:26
 
| Please make sure that you have completed this tutorial before proceeding further.
 
| Please make sure that you have completed this tutorial before proceeding further.
  
 
|-
 
|-
| 09.32
+
| 09:32
 
| Watch the video available at the following link.
 
| Watch the video available at the following link.
  
 
|-
 
|-
| 09.35
+
| 09:35
 
| It summarizes the Spoken Tutorial Project
 
| It summarizes the Spoken Tutorial Project
  
 
|-
 
|-
| 09.38
+
| 09:38
 
|If you do not have good bandwidth you can download and watch it
 
|If you do not have good bandwidth you can download and watch it
  
 
|-
 
|-
|09.42
+
|09:42
 
| The Spoken Tutorial Project Team
 
| The Spoken Tutorial Project Team
  
 
|-
 
|-
| 09.45
+
| 09:45
 
| Conducts workshops using spoken tutorials
 
| Conducts workshops using spoken tutorials
  
 
|-
 
|-
| 09.48
+
| 09:48
 
| Gives certificates for those who pass an online test
 
| Gives certificates for those who pass an online test
  
 
|-
 
|-
| 09.52
+
| 09:52
 
| For more details please write to contact at spoken hyphen tutorial dot org
 
| For more details please write to contact at spoken hyphen tutorial dot org
  
 
|-
 
|-
| 09.58
+
| 09:58
 
| Spoken Tutorial Project is a part of the Talk to a Teacher Project
 
| Spoken Tutorial Project is a part of the Talk to a Teacher Project
  
 
|-
 
|-
| 10.02
+
| 10:02
 
| It is supported by the National Mission on Education through ICT, MHRD, Government of India
 
| It is supported by the National Mission on Education through ICT, MHRD, Government of India
 
|-
 
|-
| 10.09
+
| 10:09
 
| More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro
 
| More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro
  
 
|-
 
|-
| 10.19
+
| 10:19
 
| The Library Management System has been contributed by a leading software MNC, through their Corporate Social Responsibility Programme.
 
| The Library Management System has been contributed by a leading software MNC, through their Corporate Social Responsibility Programme.
  
 
|-
 
|-
| 10.28
+
| 10:28
 
|They have also validated the content for this spoken tutorial.
 
|They have also validated the content for this spoken tutorial.
  
 
|-
 
|-
| 10.32
+
| 10:32
 
|This is Arya Ratish from IIT Bombay signing off.
 
|This is Arya Ratish from IIT Bombay signing off.
  

Revision as of 16:26, 18 September 2014

Time Narration
00:01 Welcome to the spoken-tutorial on Servlet Methods.
00:06 In this tutorial we will learn to
00:08 create a simple login form using JSP
00:13 Pass parameters using doGet method
00:16 Pass parameters using doPost method
00:20 Difference between doGet and doPost methods
00:25 Here we are using
00:26 Ubuntu Version 12.04
00:30 Netbeans IDE 7.3
00:33 JDK 1.7
00:36 Firefox web-browser 21.0
00:39 You can use any web-browser of your choice.
00:43 To follow this tutorial you must know
00:46 Core Java using Netbeans IDE
00:49 HTML
00:51 Basics of Java Servlets and JSPs
00:56 If not, for relevant tutorials please visit our website.
01:00 We will begin by creating our web application- the Library Management System.
01:06 First, we will create the home page.
01:09 The home page will contain a simple login form.
01:14 It will allow authenticated users to login to the Library Management System.
01:20 Now, let us switch to Netbeans IDE.
01:23 Let us go to the index dot jsp page, that we had already modified earlier.
01:30 I have modified this page to create our home page.
01:35 We keep the title as Home Page.
01:38 Inside the body, we have a table,with border equal to 1.
01:44 You can have a look at the code here.
01:47 Inside the table we have included a heading, Welcome to Library Management System.
01:54 Next, we have paragraph tag that includes, This is the home page for Library Management System.
02:03 Then, we have a hyperlink, which links to a page called visitorHomePage dot jsp.
02:11 We will create this page later.
02:13 Next,we have a very simple login form.
02:18 This form allows a registered user to login .
02:22 Before creating the form you will have to create a servlet named GreetingServlet.
02:28 Pause the tutorial and create a new servlet as explained in the earlier tutorial.
02:35 Note that the servlet name is GreetingServlet.
02:39 The URL pattern should be GreetingServletPath.
02:44 This form has two input elements - Username and Password.
02:50 It also has a Submit button that says Sign In.
02:55 Next, we have a paragraph tag that includes a link to addUser.jsp.
03:03 This is the registration page for those users who have not yet registered.
03:09 Now, let us go to our GreetingServlet.java.
03:14 Note that GreetingServlet.java is created in the same package org.spokentutorial.
03:23 Now, this servlet will be able to access the form data from the request object.
03:30 This servlet will act as a controller.
03:33 Do you recall that we had come across controller earlier?
03:38 Now, we will see what the servlet does as a controller.
03:42 The form data will reside in the request object.


03:46 The first task is to retrieve the form data parameters.
03:51 This is done using the getParameter method on the request object.
03:57 So, let us switch to Netbeans IDE.
04:02 Type inside the doGet method,
04:04 PrintWriter space out equal to response dot getWriter.
04:14 Next, we will retrieve the form data parameters.
04:18 So that on the next line type,
04:20 String' space username equal to request dot getParameter within brackets and double quotes userName'semicolon.
04:35 Note that this userName is the name we have included in the form tag for User Name.
04:43 Similarly, we will retrieve the password also.
04:48 So on the next line, type, String space password equal to request dot getParameter within brackets and double quotes password semicolon.
05:03 Next, we will print the User Name in the output.
05:08 So, on the next line type
05:10 'out dot println within brackets and double quotes Hello from GET Method plus username.
05:21 Now, to run this project, right-click on MyFirstProject.
05:27 Click on Clean and Build.
05:29 Again right click on MyFirstProject , click on Run.
05:35 So, the server is up and running.
05:38 It has deployed MyFirstProject.
05:41 We have got our home page displayed in the browser.
05:45 Observe that the title of the page is Home Page.
05:50 We can see a very simple login form here.
05:54 Let me enter the Username and Password.
05:58 I will type arya as the Username.
06:02 And arya*123 as the Password.
06.06 Then click on Sign In.
06:09 We can see that we have got the output Hello from GET Method arya.
06:15 Now, the user was able to login here because we have not included any validation inside the code.
06:24 We will do this in the later tutorial.
06:28 Now, have a look at the URL here.
06:31 It is localhost colon 8080 slash MyFirstProject slash GreetingServletPath question mark userName equal to arya and password equal to arya *123.
06:49 Now, form data is separated from the page information by a question mark.
06:56 We can see that username and password that we had entered in the form is inside the URL also.
07:05 Now, let us try to do the same using POST Method.
07:10 So, switch back to the IDE.
07:12 Copy the code we had written for doGet Method and paste in the doPost Method.
07:20 Now, change the println statement to Hello from POST Method.
07:27 Now, let us open index dot jsp.
07:31 Here, we must change the method attribute of the form tag to POST.
07:37 You can have a look at this code now.
07:42 We have form action equal to GreetingServletPath method equal to POST.
07:49 Now, we will run this Project again
07:53 So, Right click on MyFirstProject and click on Run
07:58 We have got an output similar to the one we got, when we used the GET method.
08:04 So let us type User Name and Password again.
08:08 Then click on Sign In.
08:12 Note that we have got Hello from POST Method arya.
08:17 Now, take a look at the URL.
08:19 It is localhost colon 8080 slash MyFirstProject slash GreetingServletPath
08:25 Here we do not see the form data in the URL of the request.
08:30 This is the major difference between doGet and doPost Methods.
08:35 Now, let us learn when to use GET and when to use POST Methods.
08:42 GET Method is used when:
08:44 the form is small and hence the data is less.
08:48 the user wants the contents of the data to be visible in the URL.
08:53 POST Method is used when:
08:55 the form is large and hence the data is more.
09:00 the user does not want the contents of the data to be visible in the URL.
09:06 ex: passwords
09:08 Let us summarize.
09:10 In this tutorial we have learnt to:
09:12 create a simple login form using JSP
09:16 Pass parameters using doGet method
09:19 Pass parameters using doPost method
09:22 Difference between doGet and doPost methods
09:26 Please make sure that you have completed this tutorial before proceeding further.
09:32 Watch the video available at the following link.
09:35 It summarizes the Spoken Tutorial Project
09:38 If you do not have good bandwidth you can download and watch it
09:42 The Spoken Tutorial Project Team
09:45 Conducts workshops using spoken tutorials
09:48 Gives certificates for those who pass an online test
09:52 For more details please write to contact at spoken hyphen tutorial dot org
09:58 Spoken Tutorial Project is a part of the Talk to a Teacher Project
10:02 It is supported by the National Mission on Education through ICT, MHRD, Government of India
10:09 More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro
10:19 The Library Management System has been contributed by a leading software MNC, through their Corporate Social Responsibility Programme.
10:28 They have also validated the content for this spoken tutorial.
10:32 This is Arya Ratish from IIT Bombay signing off.


Thank you for joining.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14