j'c'westlakestaffs'ac'uk - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

j'c'westlakestaffs'ac'uk

Description:

The update a database problem. Tackling the problem. An update Guest JSP walkthrough ... JSP code snippets. To stop the key (email) text box being changed ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 10
Provided by: jonathan76
Category:

less

Transcript and Presenter's Notes

Title: j'c'westlakestaffs'ac'uk


1
JSP the update database problem
  • Format of lecture
  • The update a database problem
  • Tackling the problem
  • An update Guest JSP walkthrough
  • Summary

2
The update problem
  • How to tackle for the assignment?
  • What do we need to do? See below
  • Steps
  • Understand the SQL we can use
  • What can we use we have developed already? See
    next slide
  • Solution using the Guests example
  • We need to
  • Allow the user to select a guest record
  • View it
  • Modify it and write it back to the database i.e.
    update it
  • Are there any aspects we dont wish to allow the
    user to do
  • Yes they cannot alter the key in this case
    email address.

3
The update problem
  • What can we use that we have already developed?
  • Answer lots
  • We can modify the html form we used for selecting
    a guest to delete to be select a guest to update
  • The html form can call a jsp which simply
    displays the result in a set of text boxes rather
    than a table format
  • We can allow the user to change the content of
    the text box for firstname and lastname and then
    call a jsp to do the update to the database and
    then call another jsp to display the confirmation

4
(No Transcript)
5
(No Transcript)
6
JSP code snippets
  • To stop the key (email) text box being changed
  • ltTABLE BORDER"1" WIDTH"50" ALIGN"center"
    BGCOLOR"lightgreen" CELLPADDING"2"gt ltTRgt
  • ltTD WIDTH"25"gtltBgtEmaillt/Bgtlt/TDgt
  • ltTD WIDTH"25"gtltINPUT TYPE"text" SIZE"25"
    READONLY"true" NAME"email" VALUE"lt email
    gt"gtlt/TDgt

7
Next stage
  • A JSP which can use the parameters from the
    update form and call a bean to update the
    database
  • So required another JSP
  • Copy and modify the AddGuests JSP see code
  • A bean
  • Copy and modify GuestBean
  • Will have a method to update the database
  • Use the Update SQL command
  • String sql "UPDATE Guests SET
    GuestBook.firstName'" this.fName
    "',GuestBook.lastname this.lName "' WHERE
    email '" email "'"
  • statement.executeUpdate(sql)

8
Demo
  • Now follows

9
Your assignment
  • You can use the same approach to modify an and
    update an order
Write a Comment
User Comments (0)
About PowerShow.com