Sadp 5
Sadp 5
Introduction
Distributed systems involve multiple interconnected computer systems that process data
across different locations, providing advantages such as increased efficiency, reliability, and
cost-effectiveness. These systems allow data processing at the point of origin, resource
sharing, and improved fault tolerance since the failure of one system does not compromise
the entire network. However, distributed systems come with challenges, including the
complexity of software design, potential slow data access due to communication links, and
security concerns.
Distributed systems can be categorized into peer-to-peer systems and client/server systems.
While peer-to-peer systems involve equal nodes running identical algorithms, the
client/server approach is more commonly used in commercial applications. In this model,
clients send requests to servers, which process them and return results. Modern client
software often includes web browsers, enabling interaction with servers.
In its simplest form, a client/server system consists of multiple clients and a single server.
Each client runs a user interface (e.g., GUI or non-GUI) that interacts with users. The server
hosts an object-oriented system, processes client requests, and sends results back to the
clients. This design can easily be extended to include multiple servers.
A challenge in client/server systems arises when objects exist in different Java Virtual
Machines (JVMs). Each JVM has its own address space, so objects in one JVM cannot
directly access objects in another JVM. For instance, accessing an object in JVM2 from
JVM1 using its address may lead to errors due to conflicting memory interpretations.
This section explains Java Remote Method Invocation (RMI) and its implementation for
building client-server systems. Here's a summary of key points:
• Proxies (Stubs): Act as client-side representatives for remote objects. Stubs handle
marshalling (assembling method calls into messages) and sending them to the server.
• Server-Side: The server unmarshalls messages, invokes the appropriate method on
the remote object, and sends results back.
Web-based applications have become widespread for tasks like booking tickets, shopping,
and making reservations. Here's a summary of their key aspects:
1. Client-Server Model:
o The browser acts as a general-purpose client that communicates with servers
via HTTP.
o Browsers primarily display server-generated HTML and transmit user inputs
to servers.
o Minimal computation happens on the client side.
2. Dynamic Content Generation:
o Server-side code dynamically generates HTML to personalize user
experiences (e.g., displaying specific flight booking details).
3. Server-Side Technologies:
o Popular technologies for server-side processing include:
▪ Java Server Pages (JSP)
▪ Java Servlets
▪ Active Server Pages (ASP)
▪ PHP
HTML Basics:
• HTML pages are made of a header, body, and footer. Tags like <head>, <body>, and
<title> define elements in the document.
• Tags may include attributes, such as style, to modify appearance (e.g., color or
font).
• Forms allow users to input data via <form>, <input>, and <submit> tags.
• A form uses the action attribute to specify where the data is sent, and the method
attribute to define the transmission method (GET or POST).
o GET: Data is sent in the URL; suitable for idempotent (repeatable) actions.
o POST: Data is sent in the message body; used for non-idempotent actions.
Java Servlets:
Overall Flow:
This comprehensive text outlines the process of designing and implementing a web-based
library management system. It involves transitioning an object-oriented system to a web
platform, focusing on servlet-based architecture and dynamic HTML. Here's a condensed
summary of the key points:
• URL Access: Users connect to the library system by typing its URL.
• User Types:
o Superusers: Library employees with elevated privileges, like adding books,
members, or processing holds. These operations are restricted to library
terminals.
o Ordinary Members: General users can issue or renew books, place/remove
holds, and view transactions, accessible from any terminal.
• Authentication: Superusers require unique IDs and passwords, while members use
library IDs and phone numbers.
• Command Execution: State diagrams detail access flow for logging in, issuing
books, and other operations.
2. Interface Requirements
• State Transition Diagrams: Depict user interactions for commands (e.g., Add Book,
Issue Book).
• Common Operations:
o Log in for access.
o Command execution with a cancel option.
o Exit to terminate sessions.
3. Design Components
5. Session Management
• Sessions track user identities, roles, and privileges across requests using
HttpSession. Methods include:
o Create a session: getSession()
o Store attributes: setAttribute(String name, Object value)
o Retrieve attributes: getAttribute(String name)
o End a session: invalidate()
6. Server Configuration
• The system operates on an Apache Tomcat server, which acts as a servlet container.
The servlets process user requests and deliver dynamic responses.
Command Handling
• Adding/Removing Books:
o Similar flow: form creation, submission handling, result generation.
• Renewing Books:
o More complex due to iterative processing of multiple books:
▪ Checkbox controls for selecting books to renew.
▪ Attributes store book details for state management across requests.
Key Components:
1. LibraryServlet:
o Loads privileged users and IP addresses into memory during initialization.
o Provides methods for validating users and managing user sessions.
2. IndexServlet:
o Handles user login by accepting user ID and password.
o Calls the getMenu method in MenuBuilder for user validation and menu
creation.
3. MenuBuilder:
o Responsible for checking user credentials and assembling appropriate menus.
o Utilizes methods from LibraryServlet for user validation.
Process Workflow:
1. Login Process:
o User enters credentials (user ID and password).
o Validation:
▪ validateSuperUser: Checks if the user is a privileged superuser.
▪ validateOrdinaryMember: Checks if the user is a regular library
member.
▪ If validation fails, the login screen is redisplayed with an error
message.
o Attribute Setup:
▪ Sets attributes like userType (Privileged/Ordinary), location
(Library/Outside), and currentUserId in the request object.
o Menu Generation:
▪ Calls the getMenu method to generate a personalized menu based on
user type and location.
2. Menu Options:
o Privileged Users:
▪ Commands like Add and Remove Book (if logged in from the library).
o Ordinary Members:
▪ Commands like Place Hold and Remove Hold.
o Global Commands:
▪ Available to all users, including the Exit command.
3. Location Check:
o Determines whether the login is from within the library or from an external
terminal.
o Adjusts the menu accordingly.
4. Logout Process:
o Resets user attributes and navigates back to the main or login menu.
o For privileged users, clears the currentUserId attribute.
Menu Assembly:
• The getMenu method uses the following files to construct the HTML:
1. HEADER: Common header content.
2. LIBRARY_COMMANDS: Commands for users in the library.
3. PRIVILEGED_COMMANDS: Additional commands for superusers.
4. GLOBAL_COMMANDS: Commands available universally.
5. EXIT_COMMAND: Exit option.
6. END_PAGE: Common footer content.