Format of lecture: - PowerPoint PPT Presentation

Loading...

PPT – Format of lecture: PowerPoint presentation | free to view - id: 154507-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Format of lecture:

Description:

The membership aspect you can tackle with the JSPs we have reviewed over the ... This is like building an office block from the blueprint. ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 33
Provided by: jonathan76
Category:
Tags: and | block | format | lecture | tackle

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Format of lecture:


1
JSP models
  • Format of lecture
  • Assignment context Register as a member of the
    site/show member details/update member details
  • JSP models
  • JSPs calling other JSPs i.e. breaking up work
  • JSPs with Update SQL examples
  • Summary
  • Assignment Progress review making sure you are
    clear about what you are doing with the prototype
  • Java Beans notes and demo

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
  • Let the user view it
  • Allow the user to modify it (not key however) and
    then 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 and in this case the lastname

3
The update solution
  • So.we need ..
  • The form that call a jsp which simply displays
    the result from the fetch in a set of text boxes
    rather than a table format this allow the user
    to do something with the data
  • We can allow the user to change the content of
    the text box for firstname and then call a jsp to
    do the update to the database and then call
    another jsp to display the confirmation or return
    to our starting point

4
UPDATE SQL
  • A JSP which can use the parameters from the
    update form and call a JSP to update the database
  • Use the Update SQL command

5
Demo
  • Now follows
  • Ive put the example in a folder on jw5 called
    updateguestexamples_withoutbean

6
Your assignment
  • You can use the same approach to modify an and
    update a member entry in the database

7
Summary
  • You have seen an update example with and without
    the use of bean technology
  • This type of web design starts to look like a
    service oriented structure i.e. JSPs that will
    service other JSPs or HTML forms given the
    appropriate information

8
Assignment progress
  • A walkthrough of some of my thoughts of the
    prototype to meet the requirements
  • These thoughts should marry with thoughts you
    have had so far
  • Hope this focuses your attention on the decision
    making you are faced with
  • What problems do you need to make a decision on

9
Assignment progress
  • You should have by now thought of a sequence of
    events that the prototype needs to follow your
    work in UML should help you with this
  • Use Case Script
  • OSD
  • The membership aspect you can tackle with the
    JSPs we have reviewed over the last two weeks
    add a member view and update a member
  • How much detail do we need to hold about a
    member?
  • Email address name .do we need anything else?

10
(No Transcript)
11
Assignment Progress
  • Your next thought process should be about the
    orders aspect
  • Fact you need to understand how the 3rd party
    shopping cart works what will it accept true
    OO we dont need to know how it is built but
    need to know what parameters to send it
  • Mals E-Commerce doesnt host a product page and
    so this is something you have to produce yourself
  • What do we need to send the shopping cart? The
    product selected by the member and other
    information product descprice

12
Assignment progress
  • So how to do this?
  • There needs to be a member login form where we
    check they are a member.if yes they get directed
    to a product pagethat is what the membership is
    for to allow access see next slide which you
    will need to augment..
  • What should the product page be?
  • Choices here .it could be a simple static HTML
    page which shows products with buy now buttons
  • A buy now hypertext link to the shopping cart 3rd
    party software.example on next slide
  • Your page would just have a few example CDs or
    DVDs to demonstrate the proof of concept
  • How the buy now button links to the shopping cart
    is explained in the Mals E-Commere help but I
    will show you on the screen to be clear

13
(No Transcript)
14
Assignment Progress
15
Assignment Progress
  • Alternative to the HREF example is to use a FORM
    using POST instead of GET
  • What this means is you link to the cart using a
    HTML form instead of an ordinary hyperlink.
  • ltFORM METHOD"POST" ACTION"http//ww.aitsafe.com
    /cf/add.cfm"gtltINPUT TYPE"HIDDEN" NAME"userid"
    VALUE"gg12345"gtltINPUT TYPE"HIDDEN"
    NAME"product" VALUE"North Atlantic Marine
    Chart"gtltINPUT TYPE"HIDDEN" NAME"price"
    VALUE"29.50"gtltINPUT TYPE"SUBMIT"gt lt/FORMgt
  • You can add something to the cart using a drop
    down list, radio buttons or any HTML form tag.

16
Assignment Progress
17
Assignment Progress
  • Alternatively you could do a more sophisticated
    product page.but you have not been requested to
    do this.
  • This would involve a products table
  • A form which retrieves the products and shows
    them to the user very similar to the update
    guest example
  • The user then selects a product to buy
  • The difference with this solution would be that
    the products displayed would be dynamic i.e. from
    the database

18
Orders use of shopping cart
  • Add order via shopping cart. An order can be
    for more than one item
  • Deleting orders via shopping cart just make
    sure all quantities are zero and this will empty
    the shopping cart
  • Update order via shopping cart change
    quantity or remove item by zero quantity
  • To retrieve a finished order would involve the
    use of the mOrders add on from Mals E-Commerce

19
Assignment Progress
20
Java Beans
  • What now follows are notes and a demo of
    component technology called Java Beans
  • No need to do this for the assignment (optional)
    but an understanding is necessary for the exam
  • The OO ness of Beans is the interesting aspect

21
Java Server Pages and beans!
  • The N-Tier model
  • Introduction to JavaBeans
  • How JSP and JavaBeans can work together
  • Demo

22
The N-tier model
  • Up to know we have used 2 tier i.e the client
    (presentation) and the http server (JSP
    application)
  • For N-tier - where we are heading? - we will use
    our HTTP server for java beans and JSPs
  • N-tier means separation of data application
    logic presentation Why is this good software
    engineering? Discussion ..
  • We can introduce JavaBeans as a tier - the JSP
    will talk to the bean and the bean can handle
    for example access to a database
  • Beans can be used by many JSPs for common
    functionality and can help to slim down the JSP
    code
  • Therefore, what are JavaBeans? They can be
    thought as middleware but we need more detail
    than that

23
Java Beans a definition
  • JavaBeans are a portable, platform independent
    component model written in the Java programming
    language, developed in collaboration with
    industry leaders, e.g. IBM. Circa 1998.
  • They enable developers to write reusable
    components once and run them anywhere, benefiting
    from the platform independence power of Java
    technology.
  • See the JavaBeans homepage link below for more
    info http//java.sun.com/products/javabeans/
  • Java beans are useful and at Enterprise level
    they are called Enterprise Java Beans (EJBs)

24
JavaBeans nuts and bolts
  • A JavaBean is developed as a .java file extension
  • It HAS to be compiled into a .class file
    extension
  • The name of the Bean MUST match the name of the
    class
  • The Bean cannot be run standalone - it has to be
    called by another Java program - in our case a
    JSP
  • the JavaBean has no main method (therefore it
    cannot run on its own accord)
  • it can have variables and methods which can be
    called by another Java program in our case a JSP

25
JavaBeans objects
  • A JavaBean is a Java class.
  • A class is a blueprint that represents some
    real-world entity that we wish to model in our
    system.
  • This blueprint specifies the structure of the
    data for the entity and a series of methods
    (functions) that can act upon that data.
  • To work with a class in our code, we build an
    object from the class. This is like building an
    office block from the blueprint.
  • So, on the server we could have many objects of
    the JavaBean class in existence (i.e. my use of
    the JavaBean would create an object, another
    users use of the JavaBean would create another
    object two separate objects that share a
    similar structure).
  • Therefore we can conclude that JavaBeans can be
    used in a multi-user environment.

26
Forward model
  • Forward model

The JSP parses the input from the HTML form and
stores it in a javabean and updates the database
Client Request
HTTP Server - Tomcat
JSP
HTML Form
SQL
JSP
BEAN
Response
DATABASE
27
Forward model
  • JSPs are chained in the Forwarding requests
    model.
  • A JSP accepts a request from the user, possibly
    uses a JavaBean and then forwards the request to
    another JSP - hence the above term of chaining
    JSPs together.
  • This is different to the include model as there
    is no primary JSP responsible for sending the
    response back to the user.

28
Demo of a Guestbook_example bean using forward
action
  • Demo consists of
  • An HTML form InputGuest_example.html
  • A JSP which parses the form AddGuests_example.jsp
  • A call to the compiled bean to do an addition
    to the database GuestBean_example.java
  • A forward action to a JSP to show the results.

29
Summary
  • It should have struck you by now that a JavaBean
    can be used by many JSPs - this is good practice.
  • For example, the GuestBean can service a number
    of different JSPs.
  • a JSP to add Guests.
  • a JSP to delete Guest.
  • How? Answer - by providing a method which the
    JSPs can call - see next slide for diagram.

30
GuestBean
AddGuests.jsp
DeleteGuests.jsp
ltjspuseBean id"GUESTS" class"jonathansbeans.Gue
stBean" scope"request" /gt ltjspsetProperty
name"GUESTS" property"" /gt ltBRgt lt
GUESTS.updateDatabase() gt
ltjspuseBean id"GUESTS" class"jonathansbeans.Gue
stBean" scope"request" /gt ltjspsetProperty
name"GUESTS" property"" /gt ltBRgt lt
GUESTS.updateDatabasefordelete() gt
31
Benefits of beans?
  • Separation of work and herein lies the
    advantages
  • simplification.
  • reducing the size of JSPs by delegating work out
    to beans.
  • One disadvantage of forward model is that one JSP
    is responsible for the request and another JSP
    takes care of the response - could get messy if
    the chain was big.

32
(No Transcript)
About PowerShow.com