Difference between revisions of "Java-Business-Application/C2/Creating-and-viewing-inventories/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
(12 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
|- | |- | ||
| 00:07 | | 00:07 | ||
− | | In this tutorial we will learn | + | | In this tutorial, we will learn: |
|- | |- | ||
| 00:09 | | 00:09 | ||
− | | | + | |To modify the '''login''' page to redirect to '''admin page''' |
|- | |- | ||
| 00:14 | | 00:14 | ||
− | |To fetch all the book details | + | | To fetch all the book details |
|- | |- | ||
Line 25: | Line 25: | ||
|- | |- | ||
| 00:20 | | 00:20 | ||
− | | To display the books borrowed by logged in user | + | |To display the books borrowed by a logged in user. |
|- | |- | ||
| 00:25 | | 00:25 | ||
− | | Here we are using | + | | Here we are using: |
|- | |- | ||
| 00:27 | | 00:27 | ||
− | | '''Ubuntu Version''' 12.04 | + | | '''Ubuntu''' Version '''12.04''' |
|- | |- | ||
| 00:29 | | 00:29 | ||
− | | '''Netbeans IDE | + | | '''Netbeans IDE 7.3''' |
|- | |- | ||
| 00:32 | | 00:32 | ||
− | | '''JDK | + | | '''JDK 1.7''' |
|- | |- | ||
| 00:34 | | 00:34 | ||
− | | '''Firefox''' web-browser 21.0 | + | | '''Firefox''' web-browser '''21.0''' |
|- | |- | ||
Line 53: | Line 53: | ||
|- | |- | ||
| 00:42 | | 00:42 | ||
− | | To follow this tutorial you must have knowledge of | + | | To follow this tutorial, you must have knowledge of: |
|- | |- | ||
Line 61: | Line 61: | ||
|- | |- | ||
| 00:50 | | 00:50 | ||
− | | Database and validation of fields | + | | Database and validation of '''fields'''. |
|- | |- | ||
Line 69: | Line 69: | ||
|- | |- | ||
| 00:57 | | 00:57 | ||
− | | Now, let us switch to '''NetBeans IDE ''' | + | | Now, let us switch to '''NetBeans IDE '''. |
|- | |- | ||
Line 77: | Line 77: | ||
|- | |- | ||
| 01:04 | | 01:04 | ||
− | |You can see the different fields in the table | + | |You can see the different '''fields''' in the '''table'''. |
|- | |- | ||
Line 89: | Line 89: | ||
|- | |- | ||
| 01:18 | | 01:18 | ||
− | |I have inserted 5 entries into '''Checkout''' table. | + | |I have inserted 5 entries into the '''Checkout''' table. |
|- | |- | ||
Line 113: | Line 113: | ||
|- | |- | ||
|01:43 | |01:43 | ||
− | | So I will type the '''username''' and '''password''' as '''admin.'''Then click on '''Sign In.''' | + | | So, I will type the '''username''' and '''password''' as '''admin.''' Then click on '''Sign In.''' |
|- | |- | ||
Line 125: | Line 125: | ||
|- | |- | ||
| 02:02 | | 02:02 | ||
− | |We will see | + | |We will see, how we modified the '''GreetingServlet '''to redirect to '''Admin Page.''' |
|- | |- | ||
Line 133: | Line 133: | ||
|- | |- | ||
|02:13 | |02:13 | ||
− | | Here we check if '''username''' and '''password ''' | + | | Here we check if '''username''' and '''password '''equal '''admin.''' |
|- | |- | ||
Line 165: | Line 165: | ||
|- | |- | ||
| 02:49 | | 02:49 | ||
− | |It has all the details like '''Book Id, | + | |It has all the details like- '''Book Id, Book Name, Author Name, ISBN, Publisher, Total Copies''' and '''Available copies.''' |
|- | |- | ||
|02:59 | |02:59 | ||
− | |Now I will show you how this is done. | + | |Now, I will show you how this is done. |
|- | |- | ||
Line 177: | Line 177: | ||
|- | |- | ||
| 03:05 | | 03:05 | ||
− | | Now, let us come to '''adminsection | + | | Now, let us come to '''adminsection ''' dot '''jsp.''' |
|- | |- | ||
Line 189: | Line 189: | ||
|- | |- | ||
| 03:19 | | 03:19 | ||
− | | We can see that in '''adminsection | + | | We can see that in '''adminsection ''' dot '''jsp''', we have '''form action ''' equal to '''AdminSection'''. |
|- | |- | ||
| 03:28 | | 03:28 | ||
− | | Now, Open '''AdminSection | + | | Now, Open '''AdminSection ''' dot '''java.''' |
|- | |- | ||
Line 201: | Line 201: | ||
|- | |- | ||
| 03:36 | | 03:36 | ||
− | |We clicked on '''List''' | + | |We clicked on '''List Books'''. |
|- | |- | ||
| 03:39 | | 03:39 | ||
− | | So this part of the query will be executed. | + | | So, this part of the query will be executed. |
|- | |- | ||
| 03:44 | | 03:44 | ||
− | |We execute query to fetch books from '''Books table.''' | + | |We execute the query to fetch books from '''Books table.''' |
|- | |- | ||
| 03:49 | | 03:49 | ||
− | |Next we create '''ArrayList''' to store the details of the books | + | |Next, we create '''ArrayList''' to store the details of the books. |
|- | |- | ||
| 03:55 | | 03:55 | ||
− | | Then we iterate through the '''result set''' | + | | Then we iterate through the '''result set'''. |
|- | |- | ||
| 03:59 | | 03:59 | ||
− | |We create the '''Book''' object | + | |We create the '''Book''' object. |
|- | |- | ||
|04:03 | |04:03 | ||
− | | We set '''BookId '''into the '''Book '''object | + | | We set '''BookId '''into the '''Book '''object. |
|- | |- | ||
| 04:08 | | 04:08 | ||
− | |Similarly we set other attributes of the book into '''Book ''' | + | |Similarly, we set other attributes of the book into the '''Book '''object. |
|- | |- | ||
Line 241: | Line 241: | ||
|- | |- | ||
| 04:26 | | 04:26 | ||
− | | Then we forward the '''request '''to '''listBooks.jsp '''using '''RequestDispatcher''' | + | | Then we forward the '''request '''to '''listBooks.jsp '''using '''RequestDispatcher'''. |
|- | |- | ||
| 04:33 | | 04:33 | ||
− | | Now we come to '''listBooks.jsp''' | + | | Now, we come to '''listBooks.jsp'''. |
|- | |- | ||
| 04:38 | | 04:38 | ||
− | |In this page '''admin '''can view list of books. | + | |In this page, '''admin '''can view the list of books. |
|- | |- | ||
− | | | + | | 04:43 |
− | | Here, first we obtain the '''books''' from '''request'''. | + | | Here, first we obtain the '''books''' from the '''request'''. |
|- | |- | ||
|04:48 | |04:48 | ||
− | + | | This '''HTML table''' will display the details of the books. | |
− | | This '''HTML table''' will display details of the books. | + | |
|- | |- | ||
| 04:54 | | 04:54 | ||
− | | So we will iterate through the book list. | + | | So, we will iterate through the '''book list'''. |
|- | |- | ||
Line 270: | Line 269: | ||
|- | |- | ||
| 05:02 | | 05:02 | ||
− | | Similarly we display other attributes of the book. | + | | Similarly, we display other attributes of the book. |
|- | |- | ||
Line 282: | Line 281: | ||
|- | |- | ||
| 05:14 | | 05:14 | ||
− | | Click on '''List | + | | Click on '''List Borrowed Books.''' |
|- | |- | ||
| 05:17 | | 05:17 | ||
− | |And ''' | + | |And click on the '''Submit button.''' |
|- | |- | ||
|05:20 | |05:20 | ||
− | |We see a '''list '''of all the '''Books ''' | + | |We see a '''list '''of all the '''Books issued'''. |
|- | |- | ||
Line 298: | Line 297: | ||
|- | |- | ||
| 05:29 | | 05:29 | ||
− | | Now,I will switch back to the '''IDE | + | | Now, I will switch back to the '''IDE''' |
|- | |- | ||
| 05:32 | | 05:32 | ||
− | | | + | |and show you the code for the same. |
|- | |- | ||
Line 326: | Line 325: | ||
|- | |- | ||
| 05:59 | | 05:59 | ||
− | |Then we iterate through the borrowed books | + | |Then we iterate through the '''borrowed books''' |
|- | |- | ||
| 06:02 | | 06:02 | ||
− | | | + | |and set it into '''request''' as '''checkout '''attribute. |
|- | |- | ||
| 06:07 | | 06:07 | ||
− | |Now we come to '''listBorrowedBooks.jsp''' | + | |Now, we come to '''listBorrowedBooks.jsp'''. |
|- | |- | ||
Line 342: | Line 341: | ||
|- | |- | ||
|06:17 | |06:17 | ||
− | | We iterate through the '''Checkout''' list | + | | We iterate through the '''Checkout''' list |
|- | |- | ||
| 06:20 | | 06:20 | ||
− | | | + | |and here we display the attributes of the '''Checkout.''' |
|- | |- | ||
Line 354: | Line 353: | ||
|- | |- | ||
| 06:28 | | 06:28 | ||
− | | Now, switch back to the | + | | Now, switch back to the browser. |
|- | |- | ||
| 06:30 | | 06:30 | ||
− | | In the borrowed books page we have one more '''list | + | | In the '''borrowed books page''', we have one more '''list'''. |
|- | |- | ||
| 06:36 | | 06:36 | ||
− | |The '''list '''of '''books ''' | + | |The '''list '''of '''books issued''' when the '''current date '''is more than the '''return date.''' |
|- | |- | ||
Line 378: | Line 377: | ||
|- | |- | ||
| 06:56 | | 06:56 | ||
− | |In the query we give the condition | + | |In the query, we give the condition: '''return_date less than now() order by transaction_Id.''' |
|- | |- | ||
| 07:05 | | 07:05 | ||
− | | Now I will show you the interface for a normal user. | + | | Now, I will show you the '''interface''' for a normal user. |
|- | |- | ||
| 07:10 | | 07:10 | ||
− | | | + | | Switch back to the '''browser.''' |
|- | |- | ||
Line 398: | Line 397: | ||
|- | |- | ||
| 07:20 | | 07:20 | ||
− | | Type the password as '''welcome | + | | Type the password as '''welcome''' |
|- | |- | ||
| 07:22 | | 07:22 | ||
− | | | + | | and click on '''Sign In.''' |
|- | |- | ||
Line 410: | Line 409: | ||
|- | |- | ||
| 07:28 | | 07:28 | ||
− | | It has the | + | | It has the books currently borrowed by the '''user.''' |
|- | |- | ||
Line 422: | Line 421: | ||
|- | |- | ||
| 07:43 | | 07:43 | ||
− | | Now we go to '''GreetingServlet.java''' | + | | Now we go to '''GreetingServlet.java'''. |
|- | |- | ||
| 07:47 | | 07:47 | ||
− | | We display the books issued in same way as we did for the admin. | + | | We display the books issued in the same way as we did for the admin. |
|- | |- | ||
Line 434: | Line 433: | ||
|- | |- | ||
| 08:02 | | 08:02 | ||
− | | So I get the username from this line. | + | | So, I get the '''username''' from this line. |
|- | |- | ||
|08:05 | |08:05 | ||
− | | Then we fetch the details of borrowed books | + | | Then we fetch the details of borrowed books |
|- | |- | ||
| 08:10 | | 08:10 | ||
− | | | + | |with the condition '''username''' is equal to the logged-in user. |
|- | |- | ||
Line 450: | Line 449: | ||
|- | |- | ||
| 08:20 | | 08:20 | ||
− | |Then in '''successGreeting ''dot ''jsp '''we will display the list. | + | |Then, in '''successGreeting ''dot ''jsp '''we will display the list. |
|- | |- | ||
Line 458: | Line 457: | ||
|- | |- | ||
| 08:32 | | 08:32 | ||
− | | In this tutorial we have learnt to: | + | | In this tutorial, we have learnt to: |
|- | |- | ||
| 08:35 | | 08:35 | ||
− | | Modify the login page to redirect to admin page | + | | Modify the '''login page''' to redirect to '''admin page''' |
|- | |- | ||
| 08:39 | | 08:39 | ||
− | | To fetch | + | | To fetch the book details |
|- | |- | ||
| 08:42 | | 08:42 | ||
− | | To fetch borrowed book details | + | | To fetch the borrowed book details and |
|- | |- | ||
| 08:45 | | 08:45 | ||
− | | | + | | To display the books borrowed by a logged in user. |
|- | |- | ||
Line 482: | Line 481: | ||
|- | |- | ||
| 08:56 | | 08:56 | ||
− | | It summarizes the Spoken Tutorial | + | | It summarizes the Spoken Tutorial project. |
|- | |- | ||
| 08:59 | | 08:59 | ||
− | | 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:04 | | 09:04 | ||
− | | The Spoken Tutorial Project | + | | The Spoken Tutorial Project team: |
|- | |- | ||
| 09:06 | | 09:06 | ||
− | | Conducts workshops using spoken tutorials | + | | Conducts workshops using spoken tutorials. |
|- | |- | ||
| 09:09 | | 09:09 | ||
− | | Gives certificates to those who pass an online test | + | | Gives certificates to those who pass an online test. |
|- | |- | ||
| 09:13 | | 09:13 | ||
− | | 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:20 | | 09:20 | ||
− | |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. |
|- | |- | ||
| 09:24 | | 09:24 | ||
− | | 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. |
|- | |- | ||
Line 518: | Line 517: | ||
|- | |- | ||
| 09:40 | | 09:40 | ||
− | | The Library Management System has been contributed by a leading software MNC | + | | The '''Library Management System''' has been contributed by a leading software MNC through their '''Corporate Social Responsibility Program'''. |
|- | |- | ||
Line 526: | Line 525: | ||
|- | |- | ||
| 09:53 | | 09:53 | ||
− | |This is Arya Ratish from IIT Bombay signing off. | + | |This is Arya Ratish from IIT Bombay, signing off. |
|- | |- |
Latest revision as of 16:13, 28 March 2017
Time | Narration |
00:01 | Welcome to the spoken-tutorial on Creating and viewing inventories. |
00:07 | In this tutorial, we will learn: |
00:09 | To modify the login page to redirect to admin page |
00:14 | To fetch all the book details |
00:17 | To fetch borrowed book details |
00:20 | To display the books borrowed by a logged in user. |
00:25 | Here we are using: |
00:27 | Ubuntu Version 12.04 |
00:29 | Netbeans IDE 7.3 |
00:32 | JDK 1.7 |
00:34 | Firefox web-browser 21.0 |
00:38 | You can use any web-browser of your choice. |
00:42 | To follow this tutorial, you must have knowledge of: |
00:45 | Basics of Java Servlets and JSPs |
00:50 | Database and validation of fields. |
00:53 | If not, for relevant tutorials please visit our website. |
00:57 | Now, let us switch to NetBeans IDE . |
01:01 | I have created the Books table. |
01:04 | You can see the different fields in the table. |
01:08 | I have inserted 10 books into this table. |
01:12 | I have created Checkout table to store borrowed books. |
01:18 | I have inserted 5 entries into the Checkout table. |
01:24 | I have also created a model for Book and Checkout. |
01:29 | Book.java is a book model. |
01:32 | And Checkout.java is a checkout model. |
01:37 | Now, come to the browser. |
01:40 | Let us login as the admin. |
01:43 | So, I will type the username and password as admin. Then click on Sign In. |
01:51 | We can see that we come to the Admin Section Page. |
01:55 | We will come back to this page. Now let us switch to Netbeans IDE. |
02:02 | We will see, how we modified the GreetingServlet to redirect to Admin Page. |
02:08 | Let us see the GreetingServlet.java. |
02:13 | Here we check if username and password equal admin. |
02:19 | If yes, then we redirect to adminsection.jsp. |
02:25 | We have already seen how to forward to another page using RequestDispatcher. |
02:32 | Now, switch back to the browser. |
02:35 | We have two options here. |
02:37 | We will click on the radio button for List Books. |
02:41 | Then click on Submit button. |
02:44 | Here, we can see that we have the list of all the Books. |
02:49 | It has all the details like- Book Id, Book Name, Author Name, ISBN, Publisher, Total Copies and Available copies. |
02:59 | Now, I will show you how this is done. |
03:03 | Switch back to the IDE. |
03:05 | Now, let us come to adminsection dot jsp. |
03:10 | Here we have two radio buttons. |
03:14 | The first one is to list all the books. |
03:19 | We can see that in adminsection dot jsp, we have form action equal to AdminSection. |
03:28 | Now, Open AdminSection dot java. |
03:32 | Here, this checks the option that we click on. |
03:36 | We clicked on List Books. |
03:39 | So, this part of the query will be executed. |
03:44 | We execute the query to fetch books from Books table. |
03:49 | Next, we create ArrayList to store the details of the books. |
03:55 | Then we iterate through the result set. |
03:59 | We create the Book object. |
04:03 | We set BookId into the Book object. |
04:08 | Similarly, we set other attributes of the book into the Book object. |
04:16 | Then we add book object into the books list. |
04:21 | Then we set the ArrayList books into the request. |
04:26 | Then we forward the request to listBooks.jsp using RequestDispatcher. |
04:33 | Now, we come to listBooks.jsp. |
04:38 | In this page, admin can view the list of books. |
04:43 | Here, first we obtain the books from the request. |
04:48 | This HTML table will display the details of the books. |
04:54 | So, we will iterate through the book list. |
04:58 | Here we display the BookId of the book. |
05:02 | Similarly, we display other attributes of the book. |
05:07 | This is how we display the list of books. |
05:11 | Now, switch back to the browser. |
05:14 | Click on List Borrowed Books. |
05:17 | And click on the Submit button. |
05:20 | We see a list of all the Books issued. |
05:24 | It has details like Transaction Id, Book Id and Username. |
05:29 | Now, I will switch back to the IDE |
05:32 | and show you the code for the same. |
05:35 | Go to AdminSection.java. |
05:38 | We had clicked on List Borrowed Books. |
05:42 | So menuSelection is equal to List Borrowed books. |
05:47 | The steps are similar to what we saw for List Books. |
05:53 | We execute the query to fetch borrowed books details from the Checkout table. |
05:59 | Then we iterate through the borrowed books |
06:02 | and set it into request as checkout attribute. |
06:07 | Now, we come to listBorrowedBooks.jsp. |
06:12 | Here we obtain checkout from the request. |
06:17 | We iterate through the Checkout list |
06:20 | and here we display the attributes of the Checkout. |
06:25 | This is how we display Borrowed Books. |
06:28 | Now, switch back to the browser. |
06:30 | In the borrowed books page, we have one more list. |
06:36 | The list of books issued when the current date is more than the return date. |
06:43 | Switch back to IDE to see the code. |
06:46 | This is done in the same way as we did for Borrowed Books. |
06:50 | The only difference is in the SQL query. |
06:56 | In the query, we give the condition: return_date less than now() order by transaction_Id. |
07:05 | Now, I will show you the interface for a normal user. |
07:10 | Switch back to the browser. |
07:12 | Come back to the login page. |
07:15 | I will login as mdhusein. |
07:20 | Type the password as welcome |
07:22 | and click on Sign In. |
07:25 | We get a Success Greeting Page. |
07:28 | It has the books currently borrowed by the user. |
07:32 | It has details like Transaction Id, User Name, Book Id and Return Date. |
07:39 | Now, let us come back to the IDE. |
07:43 | Now we go to GreetingServlet.java. |
07:47 | We display the books issued in the same way as we did for the admin. |
07:53 | Here the difference will be that we have to display the books for the logged in user. |
08:02 | So, I get the username from this line. |
08:05 | Then we fetch the details of borrowed books |
08:10 | with the condition username is equal to the logged-in user. |
08:14 | So, we get the list of books issued for the corresponding user. |
08:20 | Then, in successGreeting dot jsp we will display the list. |
08:27 | This is how your successGreeting dot jsp will look. |
08:32 | In this tutorial, we have learnt to: |
08:35 | Modify the login page to redirect to admin page |
08:39 | To fetch the book details |
08:42 | To fetch the borrowed book details and |
08:45 | To display the books borrowed by a logged in user. |
08:50 | To know more about the spoken tutorial project, watch the video available at the following link. |
08:56 | It summarizes the Spoken Tutorial project. |
08:59 | If you do not have good bandwidth, you can download and watch it. |
09:04 | The Spoken Tutorial Project team: |
09:06 | Conducts workshops using spoken tutorials. |
09:09 | Gives certificates to those who pass an online test. |
09:13 | For more details, please write to contact at spoken hyphen tutorial dot org. |
09:20 | Spoken Tutorial Project is a part of the "Talk to a Teacher" Project. |
09:24 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
09:30 | More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro |
09:40 | The Library Management System has been contributed by a leading software MNC through their Corporate Social Responsibility Program. |
09:49 | They have also validated the content for this spoken tutorial. |
09:53 | This is Arya Ratish from IIT Bombay, signing off. |
09:57 | Thank you for joining. |