Java-Business-Application/C2/Creating-and-viewing-inventories/English-timed

From Script | Spoken-Tutorial
Revision as of 16:13, 28 March 2017 by PoojaMoolya (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14