SlideShare a Scribd company logo
1 of 31
Alva’s Institute Of Engineering And
Technology
TEAM MEMBERS:
Abhishek V Doddagoudra 4AL19IS002
Adarsh K M 4AL19IS003
Mayoori K Bhat 4AL19IS025
Shreya L 4AL19IS052
Module 5
Designing with Distributed Objects
IMPORTANT QUESTIONS
1. Compare GET and POST methods.
2. Explain how to implement object-oriented system on the web.
12.3 Implementing an Object-Oriented System on the Web
• World-wide Web is the most popular medium for hosting distributed
applications.
• The browser acts as a general purpose client that can interact with any
application that talks to it using the Hyper Text Transfer Protocol (HTTP).
• All business logic and data processing take place at the server.
• Typically, the browser receives web pages from the server in HTML and displays the
contents according to the format, a number of tags and values for the tags,
specified in it.
• The browser simply acts as a ‘dumb’ program displaying whatever it gets from the
application and transmitting user data from the client site to the server.
• The HTML program shipped from a server to a client often needs to be customized
• This requires that HTML code for the screen be dynamically constructed. This is done
by code at the server.
• For server-side processing competing technologies such as Java Server
Pages and Java Servlets, Active Server Pages (ASP), and PHP.
12.3.1 HTML and Java Servlets
• Any system that ultimately displays web pages via a browser has to
create HTML code.
• HTML code displays text, graphics such as images, links that users
can click to move to other web pages, and forms for the user to
enter data.
• An HTML program can be thought of as containing a header, a
body, and a trailer.
• The header contains code like the following:
• There are two primary ways in which form data is encoded by
the browser:
• One is GET and the other is POST.
• GET means that form data is to be encoded into a URL while
• POST makes data appear within the message itself.
12.3.2 Deploying the Library System on the World-Wide Web:
How servlets and HTML cooperate to serve web pages?
• HTML page is displayed on the client’s browser.
• The page includes, among other things, a form that allows the user to
enter some data.
• The client makes some entries in the form’s fields and submits them, say,
by clicking a button.
• The data in the form is then transmitted to the server and given to a Java
servlet, which processes the data and generates HTML code that is then
transmitted to the client’s browser, which displays the page.
12.3.2 Deploying the Library System on the World-Wide-Web:
1. Developing User Requirements
 Interface requirements
2. Design and Implementation
a. Structuring the files
b. How to remember a user
c. Configuration
d. Structure of servlets in the web-based library system
e. Execution flow
1. Developing User Requirements
Determine the system requirements:
1. The user must be able to type in a URL in the browser and connect to the library
system.
2. Users are classified into two categories: superusers and ordinary members
 superusers can execute any command when logged in from a terminal in the library,
whereas ordinary members cannot access some privileged commands.
a. Only superusers can issue the following commands: add a member, add a book,
return a book, remove a book, process holds, save data to disk, and retrieve data
from disk.
b. Ordinarymembers and superusersmay invoke the following commands: issue and
renew books, place and remove holds, and print transactions.
c. Every user eventually issues the exit command to terminate his/her session.
3. Some commands can be issued from the library only. These include all of the
commands that only the superuser has access to and the command to issue books.
4. A superuser cannot issue any commands from outside of the library. They can log
in, but the only command choice will be to exit the system.
5. Superusers have special user ids and corresponding password. For regular
members, their library member id will be their user id and their phone number will be the
password.
Interface requirements
Department
of ISE
• Large number of sequences of interactions are possible
between the user and the interface.
• Depict the requirements through state transition diagrams.
Logging in and the Initial Menu:
1.The Issue Book
command is available only
if the user logs in from a
terminal in
the library.
2. Commands to place a hold, remove a hold, print transactions, and renew books
are available to members of the library (not superusers) from anywhere.
3. Certain commands are available only to superusers who log in from a library
terminal: these are for returning or deleting books, adding members and books,
processing holds, and saving data to and retrieving data from disk.
Add Book: State transition diagram for add book
• When the command to add a
book is chosen, the system
constructs the initial screen to
add a book,
• which should contain three
fields for entering the title,
author, and id of the book,
and then display it and enter
the Add Book state.
• By clicking on a button, it should be possible for the user to submit these
values to system.
• The system must then call the appropriate method in the Library class to
create a Book object and enter it into the catalog.
• The result of the operation is displayed in the Command Completed state.
State transition diagram for saving data
• From the Command Completed state, the system must
allow the user to add another book or go back to the
menu.
• In the Add Book state, the user has the option to cancel
the operation and go back to the main menu.
State transition diagram for issuing books
A book may be checked out in two
different ways:
1. A member is allowed to check it
out himself/herself.
2. he/she may give the book to a
library staff member, who checks
out the book for the member
• In the first case, the system already has the user’s member id, so that should
not be asked again.
• In the second case, the library staff member needs to input the member id to
the system followed by the book id.
• After receiving a book id, the system must attempt to check out the book.
Whether the operation is successful or not, the system enters the Book Id
Processed state.
State transition diagram for renewing books
2. Design and Implementation
To deploy the system on the web, we need the following:
1. Classes associated with the library, create classes such as Library, Member,
Book, Catalog, and so on.
2. Permanent data (created by the save command) that stores information
about the members, books, who borrowed what, holds, etc.
3. HTML files that support a GUI for displaying information on a browser and
collecting data entered by the user.
• For example, when a book is to be returned, a screen that asks for the
book id should pop up on the browser. This screen will have a prompt
to enter the book id, a space for typing in the same, and a button to
submit the data to the system.
4. A set of files that interface between the GUI and the objects that actually
do the processing. Servlets will be used to accomplish this task.
Structuring the files
HTML code for delivery to the browser can be generated in one of two ways:
1. Embed the HTML code in the servlets. This has the disadvantage of
making the servlets hard to read, but more dynamic code can be
produced.
2. Read the HTML files from disk as a string and send the string to the
browser. This is less flexible because the code remains static.
 Create a separate HTML file for every type of page that needs to be
displayed. For example, create a file for entering the id of the book to be
returned, a second file for displaying the result of returning the book, a
third file for inputting the id of the book to be removed, a fourth one for
displaying the result of removing the book, etc.
 Exploit the commonalities between the commands and create a number
of HTML code fragments, a subset of which can be assembled to form an
HTML file suitable for a specific context.
How to remember a user
Department
of ISE
• Servlets typically deal with multiple users.
• When a servlet receives data from a browser, it must some how figure out
which user sent the message, what the user’s privileges are, etc.
• Each request from the browser to the server starts a new connection, and
once the request is served, the connection is torn down.
• Typical web transactions involve multiple request–response pairs.
• The system provides the necessary support by means of what are known as
sessions, which are of type HttpSession.
• When it receives a request from a browser, the servlet may call the method
getSession() on the HttpServletRequest object to create a session object, or
if a session is already associated with the request, to get a reference to it.
• When a user logs in, the system creates a session object as below.
HttpSession session = request.getSession();
• When the user logs out, the session is removed as below.
session.invalidate();
• Requests other than log in requires the user to be logged in. The following
code evaluates to true if the user does not have a session: that is, the user
has not logged in. request.getSession(false) == null
• A session object can be used to store information about the session. In the
library system, we would like to store the user id, the type of terminal from
which the user has logged in, and some additional information related to the
user.
1. void setAttribute(String name, Object value)
2. Object getAttribute(String name)
3. void removeAttribute(String name)
Configuration
• The server runs with the support of Apache Tomcat, which is a
servlet container.
• A servlet container is a program that supports servlet execution.
• The servlets themselves are registered with the servlet container.
URL requests made by a user are converted to specific servlet
requests by the servlet container.
• The servlet container is responsible for initialising the servlets and
delivering requests made by the client browser to the appropriate
servlet.
Structure of servlets in the web-based library system
• A servlet receives data from a
browser through a
HttpServletRequest object.
• This involves parameter names
and their values, IP address of the
user, and so on.
• For example, when the form to
add book is filled and the Add
button is clicked, the servlet’s
doPost method is invoked.
• This method has two parameters:
a request parameter of type
HttpServletRequest and a
response parameter of type
HttpServletResponse.
• These methods and doPost and
doGet are collected into a class
named LibraryServlet.
Most of the methods of LibraryServlet fall into one of five categories:
1. One group contains methods that store information about the
user.
2. Methods to validate users and help assess access rights.
3. The getFile method reads an HTML file and returns its contents
as a String object.
4. The fourth group of methods are used for handling users who
may have invoked a command without actually logging in.
5. The final group of commands deal with processing the request
and responding to it.
SELECTION STATEMENTS
 Selection statements (sometimes called conditional statements) can be defined as code that is executed
only when a certain condition is satisfied.
 Selection is a powerful tool to control when and which code statements will run.
 Selection statements are,
1. If-else statements
2. Switch statements
 Above both statements allow nesting.
If-else statement
 The if/else statement executes a block of code if a specified condition is true.
 If the condition is false, another block of code can be executed.
 The syntax is,
 Here the else part is optional.
SWITCH STATEMENT
 The switch statement allows us to handle the situation when there are numerous cases.
 The syntax is,
Loops
Loop statement helps the programmer to execute the set of instructions
repeatedly.
Java, like C and C++, allows three types of loops: for, while, and do.
While Loop
While loop is used to repeat a specific block of code an unknown number of times, until a
condition is met.
Syntax:
Example:
CASE 1: WHEN THE CONDITION IS TRUE
The loop continues
control execute the statement which belongs to the loop
after execution once the loop block ends, control goes back to the
condition and the entire process will be repeated till the condition
becomes false
CASE 2: WHEN THE CONDITION IS FALSE
The loop is stopped
the loop block will not get executed
the control comes outside the loop to the next statement.
The minimum iteration can be zero.
FOR LOOP
For loop is used to repeat a specific block of code a known number of times.
If condition is not provided by default it is considered as true.
SYNTAX
EXAMPLE
prints all integers from 10 to 25
DO LOOP
The do loop executes at least once. At the end of the first and succeeding iterations, a condition is
checked. If the condition is true, the next iteration is performed.
SYNTAX
EXAMPLE
The following example makes the user enter “yes”, “no”, or “cancel” (case-insensitive).
METHODS
Method are like functions in C. They are always enclosed within a class
declaration. A method must return void or a known type. Methods may
accept any number of parameters. Each formal argument must be written
with the type name followed by the parameter name. Parameters must be
separated by a comma.
ARRAYS
Java supports the creation of arrays of any number of dimensions. The process of creating an array
can be thought of as consisting of two steps:
1. Declare a variable that refers to the array. This is not the array itself, but eventually contains the
address of the array, which has to be dynamically allocated.
2. Allocate the array itself and make the variable declared in (1) above to point to this array.
The following code stores 1 in a[0], 2 in a[1], etc. And then prints these values.
Multi-dimensional Arrays
Multi-dimensional arrays, which will suggest how to allocate arrays of higher
dimension
EXAMPLE
Thank You

More Related Content

Similar to Module5SADP.pptx

Software requirements specification (srs) by Dan Dharma
Software requirements specification (srs) by  Dan DharmaSoftware requirements specification (srs) by  Dan Dharma
Software requirements specification (srs) by Dan DharmaAvudaiappan Dharma Ph.D.,
 
Introduction to the World Wide Web
Introduction to the World Wide WebIntroduction to the World Wide Web
Introduction to the World Wide WebAbdalla Mahmoud
 
11 Project-Online Library Management System
11 Project-Online Library Management System11 Project-Online Library Management System
11 Project-Online Library Management SystemHeather Strinden
 
Report of Student management system
Report of Student management systemReport of Student management system
Report of Student management system1amitgupta
 
11.project online library management system
11.project online library management system11.project online library management system
11.project online library management systemmonika ahalawat
 
1-informatica-training
1-informatica-training1-informatica-training
1-informatica-trainingKrishna Sujeer
 
0_Leksion_Web_Servers (1).pdf
0_Leksion_Web_Servers (1).pdf0_Leksion_Web_Servers (1).pdf
0_Leksion_Web_Servers (1).pdfZani10
 
Online old books sales by hemraj gahlot
Online old books sales by hemraj gahlotOnline old books sales by hemraj gahlot
Online old books sales by hemraj gahlotHemraj Gahlot
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 
Library management system project
Library management system projectLibrary management system project
Library management system projectAJAY KUMAR
 
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
PST SC015 Chapter 3 Internet Technology (II)  2017/2018PST SC015 Chapter 3 Internet Technology (II)  2017/2018
PST SC015 Chapter 3 Internet Technology (II) 2017/2018Fizaril Amzari Omar
 
Eba ppt rajesh
Eba ppt rajeshEba ppt rajesh
Eba ppt rajeshRajeshP153
 
Module 5 Application and presentation Layer .pptx
Module 5 Application and presentation Layer .pptxModule 5 Application and presentation Layer .pptx
Module 5 Application and presentation Layer .pptxAASTHAJAJOO
 
Librarymanagementsystem
LibrarymanagementsystemLibrarymanagementsystem
LibrarymanagementsystemJUVVANAGASAI
 
ppt-3-iotlogicdesign-210125034351.pptx
ppt-3-iotlogicdesign-210125034351.pptxppt-3-iotlogicdesign-210125034351.pptx
ppt-3-iotlogicdesign-210125034351.pptxjohnpragasam1
 
1. web technology basics
1. web technology basics1. web technology basics
1. web technology basicsJyoti Yadav
 

Similar to Module5SADP.pptx (20)

Software requirements specification (srs) by Dan Dharma
Software requirements specification (srs) by  Dan DharmaSoftware requirements specification (srs) by  Dan Dharma
Software requirements specification (srs) by Dan Dharma
 
Introduction to the World Wide Web
Introduction to the World Wide WebIntroduction to the World Wide Web
Introduction to the World Wide Web
 
11 Project-Online Library Management System
11 Project-Online Library Management System11 Project-Online Library Management System
11 Project-Online Library Management System
 
Report of Student management system
Report of Student management systemReport of Student management system
Report of Student management system
 
11.project online library management system
11.project online library management system11.project online library management system
11.project online library management system
 
1-informatica-training
1-informatica-training1-informatica-training
1-informatica-training
 
0_Leksion_Web_Servers (1).pdf
0_Leksion_Web_Servers (1).pdf0_Leksion_Web_Servers (1).pdf
0_Leksion_Web_Servers (1).pdf
 
Online old books sales by hemraj gahlot
Online old books sales by hemraj gahlotOnline old books sales by hemraj gahlot
Online old books sales by hemraj gahlot
 
Library Management System
Library Management SystemLibrary Management System
Library Management System
 
Browser
BrowserBrowser
Browser
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Library management system project
Library management system projectLibrary management system project
Library management system project
 
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
PST SC015 Chapter 3 Internet Technology (II)  2017/2018PST SC015 Chapter 3 Internet Technology (II)  2017/2018
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
 
Eba ppt rajesh
Eba ppt rajeshEba ppt rajesh
Eba ppt rajesh
 
Module 5 Application and presentation Layer .pptx
Module 5 Application and presentation Layer .pptxModule 5 Application and presentation Layer .pptx
Module 5 Application and presentation Layer .pptx
 
Ch-1_.ppt
Ch-1_.pptCh-1_.ppt
Ch-1_.ppt
 
Librarymanagementsystem
LibrarymanagementsystemLibrarymanagementsystem
Librarymanagementsystem
 
ppt-3-iotlogicdesign-210125034351.pptx
ppt-3-iotlogicdesign-210125034351.pptxppt-3-iotlogicdesign-210125034351.pptx
ppt-3-iotlogicdesign-210125034351.pptx
 
1. web technology basics
1. web technology basics1. web technology basics
1. web technology basics
 
OCSP.pptx
OCSP.pptxOCSP.pptx
OCSP.pptx
 

Recently uploaded

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

Module5SADP.pptx

  • 1. Alva’s Institute Of Engineering And Technology TEAM MEMBERS: Abhishek V Doddagoudra 4AL19IS002 Adarsh K M 4AL19IS003 Mayoori K Bhat 4AL19IS025 Shreya L 4AL19IS052 Module 5 Designing with Distributed Objects
  • 2. IMPORTANT QUESTIONS 1. Compare GET and POST methods. 2. Explain how to implement object-oriented system on the web.
  • 3. 12.3 Implementing an Object-Oriented System on the Web • World-wide Web is the most popular medium for hosting distributed applications. • The browser acts as a general purpose client that can interact with any application that talks to it using the Hyper Text Transfer Protocol (HTTP). • All business logic and data processing take place at the server. • Typically, the browser receives web pages from the server in HTML and displays the contents according to the format, a number of tags and values for the tags, specified in it. • The browser simply acts as a ‘dumb’ program displaying whatever it gets from the application and transmitting user data from the client site to the server. • The HTML program shipped from a server to a client often needs to be customized • This requires that HTML code for the screen be dynamically constructed. This is done by code at the server. • For server-side processing competing technologies such as Java Server Pages and Java Servlets, Active Server Pages (ASP), and PHP.
  • 4. 12.3.1 HTML and Java Servlets • Any system that ultimately displays web pages via a browser has to create HTML code. • HTML code displays text, graphics such as images, links that users can click to move to other web pages, and forms for the user to enter data. • An HTML program can be thought of as containing a header, a body, and a trailer. • The header contains code like the following:
  • 5. • There are two primary ways in which form data is encoded by the browser: • One is GET and the other is POST. • GET means that form data is to be encoded into a URL while • POST makes data appear within the message itself.
  • 6. 12.3.2 Deploying the Library System on the World-Wide Web: How servlets and HTML cooperate to serve web pages? • HTML page is displayed on the client’s browser. • The page includes, among other things, a form that allows the user to enter some data. • The client makes some entries in the form’s fields and submits them, say, by clicking a button. • The data in the form is then transmitted to the server and given to a Java servlet, which processes the data and generates HTML code that is then transmitted to the client’s browser, which displays the page.
  • 7. 12.3.2 Deploying the Library System on the World-Wide-Web: 1. Developing User Requirements  Interface requirements 2. Design and Implementation a. Structuring the files b. How to remember a user c. Configuration d. Structure of servlets in the web-based library system e. Execution flow
  • 8. 1. Developing User Requirements Determine the system requirements: 1. The user must be able to type in a URL in the browser and connect to the library system. 2. Users are classified into two categories: superusers and ordinary members  superusers can execute any command when logged in from a terminal in the library, whereas ordinary members cannot access some privileged commands. a. Only superusers can issue the following commands: add a member, add a book, return a book, remove a book, process holds, save data to disk, and retrieve data from disk. b. Ordinarymembers and superusersmay invoke the following commands: issue and renew books, place and remove holds, and print transactions. c. Every user eventually issues the exit command to terminate his/her session. 3. Some commands can be issued from the library only. These include all of the commands that only the superuser has access to and the command to issue books. 4. A superuser cannot issue any commands from outside of the library. They can log in, but the only command choice will be to exit the system. 5. Superusers have special user ids and corresponding password. For regular members, their library member id will be their user id and their phone number will be the password.
  • 9. Interface requirements Department of ISE • Large number of sequences of interactions are possible between the user and the interface. • Depict the requirements through state transition diagrams. Logging in and the Initial Menu: 1.The Issue Book command is available only if the user logs in from a terminal in the library. 2. Commands to place a hold, remove a hold, print transactions, and renew books are available to members of the library (not superusers) from anywhere. 3. Certain commands are available only to superusers who log in from a library terminal: these are for returning or deleting books, adding members and books, processing holds, and saving data to and retrieving data from disk.
  • 10. Add Book: State transition diagram for add book • When the command to add a book is chosen, the system constructs the initial screen to add a book, • which should contain three fields for entering the title, author, and id of the book, and then display it and enter the Add Book state. • By clicking on a button, it should be possible for the user to submit these values to system. • The system must then call the appropriate method in the Library class to create a Book object and enter it into the catalog. • The result of the operation is displayed in the Command Completed state.
  • 11. State transition diagram for saving data • From the Command Completed state, the system must allow the user to add another book or go back to the menu. • In the Add Book state, the user has the option to cancel the operation and go back to the main menu.
  • 12. State transition diagram for issuing books A book may be checked out in two different ways: 1. A member is allowed to check it out himself/herself. 2. he/she may give the book to a library staff member, who checks out the book for the member • In the first case, the system already has the user’s member id, so that should not be asked again. • In the second case, the library staff member needs to input the member id to the system followed by the book id. • After receiving a book id, the system must attempt to check out the book. Whether the operation is successful or not, the system enters the Book Id Processed state.
  • 13. State transition diagram for renewing books
  • 14. 2. Design and Implementation To deploy the system on the web, we need the following: 1. Classes associated with the library, create classes such as Library, Member, Book, Catalog, and so on. 2. Permanent data (created by the save command) that stores information about the members, books, who borrowed what, holds, etc. 3. HTML files that support a GUI for displaying information on a browser and collecting data entered by the user. • For example, when a book is to be returned, a screen that asks for the book id should pop up on the browser. This screen will have a prompt to enter the book id, a space for typing in the same, and a button to submit the data to the system. 4. A set of files that interface between the GUI and the objects that actually do the processing. Servlets will be used to accomplish this task.
  • 15. Structuring the files HTML code for delivery to the browser can be generated in one of two ways: 1. Embed the HTML code in the servlets. This has the disadvantage of making the servlets hard to read, but more dynamic code can be produced. 2. Read the HTML files from disk as a string and send the string to the browser. This is less flexible because the code remains static.  Create a separate HTML file for every type of page that needs to be displayed. For example, create a file for entering the id of the book to be returned, a second file for displaying the result of returning the book, a third file for inputting the id of the book to be removed, a fourth one for displaying the result of removing the book, etc.  Exploit the commonalities between the commands and create a number of HTML code fragments, a subset of which can be assembled to form an HTML file suitable for a specific context.
  • 16. How to remember a user Department of ISE • Servlets typically deal with multiple users. • When a servlet receives data from a browser, it must some how figure out which user sent the message, what the user’s privileges are, etc. • Each request from the browser to the server starts a new connection, and once the request is served, the connection is torn down. • Typical web transactions involve multiple request–response pairs. • The system provides the necessary support by means of what are known as sessions, which are of type HttpSession. • When it receives a request from a browser, the servlet may call the method getSession() on the HttpServletRequest object to create a session object, or if a session is already associated with the request, to get a reference to it. • When a user logs in, the system creates a session object as below. HttpSession session = request.getSession();
  • 17. • When the user logs out, the session is removed as below. session.invalidate(); • Requests other than log in requires the user to be logged in. The following code evaluates to true if the user does not have a session: that is, the user has not logged in. request.getSession(false) == null • A session object can be used to store information about the session. In the library system, we would like to store the user id, the type of terminal from which the user has logged in, and some additional information related to the user. 1. void setAttribute(String name, Object value) 2. Object getAttribute(String name) 3. void removeAttribute(String name)
  • 18. Configuration • The server runs with the support of Apache Tomcat, which is a servlet container. • A servlet container is a program that supports servlet execution. • The servlets themselves are registered with the servlet container. URL requests made by a user are converted to specific servlet requests by the servlet container. • The servlet container is responsible for initialising the servlets and delivering requests made by the client browser to the appropriate servlet.
  • 19. Structure of servlets in the web-based library system • A servlet receives data from a browser through a HttpServletRequest object. • This involves parameter names and their values, IP address of the user, and so on. • For example, when the form to add book is filled and the Add button is clicked, the servlet’s doPost method is invoked. • This method has two parameters: a request parameter of type HttpServletRequest and a response parameter of type HttpServletResponse. • These methods and doPost and doGet are collected into a class named LibraryServlet.
  • 20. Most of the methods of LibraryServlet fall into one of five categories: 1. One group contains methods that store information about the user. 2. Methods to validate users and help assess access rights. 3. The getFile method reads an HTML file and returns its contents as a String object. 4. The fourth group of methods are used for handling users who may have invoked a command without actually logging in. 5. The final group of commands deal with processing the request and responding to it.
  • 21. SELECTION STATEMENTS  Selection statements (sometimes called conditional statements) can be defined as code that is executed only when a certain condition is satisfied.  Selection is a powerful tool to control when and which code statements will run.  Selection statements are, 1. If-else statements 2. Switch statements  Above both statements allow nesting.
  • 22. If-else statement  The if/else statement executes a block of code if a specified condition is true.  If the condition is false, another block of code can be executed.  The syntax is,  Here the else part is optional.
  • 23. SWITCH STATEMENT  The switch statement allows us to handle the situation when there are numerous cases.  The syntax is,
  • 24. Loops Loop statement helps the programmer to execute the set of instructions repeatedly. Java, like C and C++, allows three types of loops: for, while, and do. While Loop While loop is used to repeat a specific block of code an unknown number of times, until a condition is met. Syntax: Example:
  • 25. CASE 1: WHEN THE CONDITION IS TRUE The loop continues control execute the statement which belongs to the loop after execution once the loop block ends, control goes back to the condition and the entire process will be repeated till the condition becomes false CASE 2: WHEN THE CONDITION IS FALSE The loop is stopped the loop block will not get executed the control comes outside the loop to the next statement. The minimum iteration can be zero.
  • 26. FOR LOOP For loop is used to repeat a specific block of code a known number of times. If condition is not provided by default it is considered as true. SYNTAX EXAMPLE prints all integers from 10 to 25
  • 27. DO LOOP The do loop executes at least once. At the end of the first and succeeding iterations, a condition is checked. If the condition is true, the next iteration is performed. SYNTAX EXAMPLE The following example makes the user enter “yes”, “no”, or “cancel” (case-insensitive).
  • 28. METHODS Method are like functions in C. They are always enclosed within a class declaration. A method must return void or a known type. Methods may accept any number of parameters. Each formal argument must be written with the type name followed by the parameter name. Parameters must be separated by a comma.
  • 29. ARRAYS Java supports the creation of arrays of any number of dimensions. The process of creating an array can be thought of as consisting of two steps: 1. Declare a variable that refers to the array. This is not the array itself, but eventually contains the address of the array, which has to be dynamically allocated. 2. Allocate the array itself and make the variable declared in (1) above to point to this array. The following code stores 1 in a[0], 2 in a[1], etc. And then prints these values.
  • 30. Multi-dimensional Arrays Multi-dimensional arrays, which will suggest how to allocate arrays of higher dimension EXAMPLE