0% found this document useful (0 votes)
93 views23 pages

M.Sc. Distributed Technologies Programs

Distributed Technology lab program

Uploaded by

ashovino28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views23 pages

M.Sc. Distributed Technologies Programs

Distributed Technology lab program

Uploaded by

ashovino28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SIR ISSAC NEWTON COLLEGE OF ARTS AND SCIENCE

I [Link]. Computer Science

DISTRIBUTED TECHNOLOGIES(P22CSCC2AP)

Page
[Link]. Date Title of Program
No.

1 RMI APPLICATION – SERVER AND CLIENT

2 WEB PAGES USING JSP SCRIPTLET

3 XML WITH XSL (STYLE SHEET)

4 XML WITH XSD (SCHEMA)

5 BASIC DATABASE OPERATIONS

6 VIEWING RECORDS

7 AD ROTATOR CONTROL
RMI APPLICATION - SERVER AND CLIENT

File: [Link]

import [Link].*;

public interface IHello extends Remote


{
public String getGreetingMessage() throws RemoteException;
}

File: [Link]

import [Link].*;

public class HelloClientComponent


{
private static final String host = "localhost";

public static void main(String[] args)


{
try
{
//We obtain a reference to the object from the registry and next,
//it will be typecasted into the most appropiate type.
IHello greeting_message = (IHello) [Link]("rmi://"
+ host + "/Hello");

//Next, we will use the above reference to invoke the remote


//object method.
[Link]("Message received: " +
greeting_message.getGreetingMessage());
}
catch (ConnectException conEx)
{
[Link]("Unable to connect to server!");
[Link](1);
}
catch (Exception ex)
{
[Link]();
[Link](1);
}
}
}
File: [Link]

import [Link].*;
import [Link].*;

public class HelloImplementation extends UnicastRemoteObject


implements IHello {

public HelloImplementation() throws RemoteException {


//There is no action need in this moment.
}

@Override
public String getGreetingMessage() throws RemoteException {
return ("SIR ISSAC NEWTON COLLEGE OF ARTS AND
SCIENCE - NAGAPATTINAM");
}
}

File: [Link]

import [Link].*;

public class HelloServerComponent {

private static final String host = "localhost";

public static void main(String[] args) throws Exception {


//** Step 1
//** Declare a reference for the object that will be implemented
HelloImplementation temp = new HelloImplementation();

//** Step 2
//** Declare a string variable for holding the URL of the object's name
String rmiObjectName = "rmi://" + host + "/Hello";

//Step 3
//Binding the object reference to the object name.
[Link](rmiObjectName, temp);

//Step 4
//Tell to the user that the process is completed.
[Link]("Binding complete...\n");
}
}
WEB PAGES USING JSP SCRIPTLET
File: [Link]

<html>
<head>
<title>Employee Salary Statement</title>
</head>
<body bgcolor="wheat">
<center>
<h3>Enter Employee Details:<h3>
<form action="[Link]" method="POST" >
<table border=2 bgcolor="lightblue">
<tr><td>Employee Name:</td><td><input type="text" name="ename"
autofocus></td></tr>
<tr><td>Basic Salary:</td><td><input type="text" name="bsal"></td></tr>
<tr><td>TA(%):</td><td><input type="text" name="ta"></td></tr>
<tr><td>DA(%):</td><td><input type="text" name="da"></td></tr>
<tr><td>HRA(%):</td><td><input type="text" name="hra"></td></tr>
<tr><td>PF(%):</td><td><input type="text" name="pf"></td></tr>
<tr><td>LIC(%):</td><td><input type="text" name="lic"></td></tr>
<tr><td><input type="submit" value="Calculate"></td>
<td><input type="reset" value="Reset"></td></tr>
</table>
</center>

File: [Link]

<html>
<head>
<title>Employee Salary Bill </title>
</head>
<body bgcolor="gold">
<%
String ename=[Link]("ename");
double bsal=[Link]([Link]("bsal"));
double ta=[Link]([Link]("ta"));
double ta2=bsal*ta/100;
double da=[Link]([Link]("da"));
double da2=bsal*da/100;
double hra=[Link]([Link]("hra"));
double hra2=bsal*hra/100;
double pf=[Link]([Link]("pf"));
double pf2=bsal*pf/100;
double lic=[Link]([Link]("lic"));
double lic2=bsal*lic/100;
double allowance;
double deduction;
double gsal;
double netsal;
allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
deduction = (bsal*pf)/100 + (bsal*lic)/100;
gsal = bsal + allowance;
netsal = gsal - deduction;
%>
<CENTER>
<table border=5 bgcolor="lightgreen" height=600 width=400 >
<caption><h2><font color="green">SALARY STATEMENT</font></h2></caption>
<tr><td>Employee Name</td><td colspan=2><%=ename%></td></tr>
<tr><td>Basic Salary</td><td colspan=2><%=bsal%></td></tr>
<tr><th>Allowances</th><th>Percentage</th><th>Amount</th></tr>
<tr align=center><td>TA</td><td><%=ta%></td><td><%=ta2%></td></tr>
<tr align=center><td>DA</td><td><%=da%></td><td><%=da2%></td></tr>
<tr align=center><td>HRA</td><td><%=hra%></td><td><%=hra2%></td></tr>
<tr><th>Total Allowance:</th><td colspan=2><%=allowance%></td><tr>
<tr><th>Deductions</th><th>Percentage</th><th>Amount</th></tr>
<tr align=center><td>PF</td><td><%=pf%></td><td><%=pf2%></td></tr>
<tr align=center><td>LIC</td><td><%=lic%></td><td><%=lic2%></td></tr>
<tr><th>Total Deduction:</th><td colspan=2><%=deduction%></td><tr>
<tr><td>Gross Salary</td><td colspan=2><%=gsal%></td></tr>
<tr><td>Net Salary</td><td colspan=2><%=netsal%></td></tr>
</table>
</CENTER>
</body>
</html>
XML WITH XSL (STYLE SHEET)

File: [Link]

<?xml version="1.0" encoding="UTF-8"?>


<?xml-stylesheet type="text/xsl" href="[Link]"?>
<cs>
<imsc>
<subtitle>ADVANCED DATABASE MANAGEMENT SYSTEM </subtitle>
<subcode>P22CSCC21</subcode>
<ciamark>25</ciamark>
<uemark>75</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle>COMPILER DESIGN </subtitle>
<subcode>P22CSCC22</subcode>
<ciamark>25</ciamark>
<uemark>75</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle>DISTRIBUTED TECHNOLOGIES </subtitle>
<subcode>P22CSCC2A</subcode>
<ciamark>25</ciamark>
<uemark>75</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle>GREEN COMPUTING</subtitle>
<subcode>P22CSCE2C</subcode>
<ciamark>25</ciamark>
<uemark>75</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle>APICULTURE</subtitle>
<subcode>P22ZONME1</subcode>
<ciamark>25</ciamark>
<uemark>75</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle> DISTRIBUTED TECHNOLOGIES LAB</subtitle>
<subcode>P22CSCC2AP</subcode>
<ciamark>40</ciamark>
<uemark>60</uemark>
<total>100</total>
</imsc>
<imsc>
<subtitle>ADVANCED DATA BASE MANAGEMENT SYSTEM LAB </subtitle>
<subcode>P22CSCC2P</subcode>
<ciamark>40</ciamark>
<uemark>60</uemark>
<total>100</total>
</imsc>
</cs>

File: [Link]

<xsl:stylesheet xmlns:xsl="[Link] version="1.0">


<xsl:template match="/">
<html>
<body>
<h2>I [Link]., Computer Science - II Semester Subjects</h2>
<table border="1">
<tr><th>Subject Title</th><th>Subject Code</th><th>CIA Marks</th><th>UE
Marks</th><th>Total Marks</th></tr>
<xsl:for-each select="cs/imsc">
<tr>
<td><xsl:value-of select="subtitle"/></td>
<td><xsl:value-of select="subcode"/></td>
<td><xsl:value-of select="ciamark"/></td>
<td><xsl:value-of select="uemark"/></td>
<td><xsl:value-of select="total"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML WITH XSD (SCHEMA)

File: [Link]

<class>
<student>
<rollno>2501</rollno>
<name>Raja</name>
<major>Computer Science</major>
<community>BC</community>
<city>Thiruvarur</city>
</student>
<student>
<rollno>2502</rollno>
<name>Ravikumar</name>
<major>Computer Application</major>
<community>MBC</community>
<city>Nagapattinam</city>
</student>
<student>
<rollno>2503</rollno>
<name>Sivakumar</name>
<major>Information Technology</major>
<community>SC</community>
<city>Mannargudi</city>
</student>
</class>
File: [Link]

<xs:schema xmlns:xs="[Link]
<xs:element name="class">
<xs:complexType>
<xs:sequence>
<xs:element name="student" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="rollno" type="xs:int"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="major" type="xs:string"/>
<xs:element name="community" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
BASIC DATABASE OPERATIONS (INSERT, UPDATE AND DELETE)

create database marksheet


use marksheet
create table mark (rno numeric(5), name varchar(20), total numeric(5))
sp_help mark
select * from mark
insert into mark (rno, name, total) values (101, 'Raja', 495)
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

public partial class _Default : [Link]


{

SqlConnection cn;
SqlCommand cmd;
string str, qry;

protected void Page_Load(object sender, EventArgs e)


{
str = @"Data Source=DESKTOP-SKHQ6MG;Initial Catalog=marksheet;Integrated
Security=True";
cn = new SqlConnection(str);
[Link]();

[Link]();
[Link] = false;
[Link] = false;
[Link] = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
int m1 = Convert.ToInt32([Link]);
int m2 = Convert.ToInt32([Link]);
int m3 = Convert.ToInt32([Link]);
int m4 = Convert.ToInt32([Link]);
int m5 = Convert.ToInt32([Link]);
int tot = m1 + m2 + m3 + m4 + m5;
[Link] = true;
[Link] = true;
[Link] = [Link]();
int percentage = tot / 5;
[Link] = [Link]();
}
protected void Button2_Click(object sender, EventArgs e)
{
qry = "insert into mark values('" + [Link] + "','" + [Link] + "','" + [Link] +
"')";
cmd = new SqlCommand(qry, cn);
[Link]();
[Link] = true;
[Link] = true;
[Link] = true;
[Link] = "Record is Inserted";

protected void Button3_Click(object sender, EventArgs e)


{
qry = "update mark set rno='" + [Link] + "', name='" + [Link] + "' where rno='"
+ [Link] + "'";
cmd = new SqlCommand(qry, cn);
[Link]();
[Link] = true;
[Link] = "Record is Updated";
}
protected void Button4_Click(object sender, EventArgs e)
{
qry = "delete from mark where rno='" + [Link] + "'";
cmd = new SqlCommand(qry, cn);
[Link]();
[Link] = true;
[Link] = "Record is Deleted";

}
protected void Button5_Click(object sender, EventArgs e)
{
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";

}
}
VIEWING RECORDS
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

public partial class _Default : [Link]


{
protected void Page_Load(object sender, EventArgs e)
{
[Link] = false;
[Link] = false;
[Link] = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
[Link] = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
[Link] = true;
}
protected void Button3_Click(object sender, EventArgs e)
{
[Link] = true;
}
}
Grid View:

Form View:
Details View

AD ROTATOR CONTROL
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="[Link]" Inherits="mgadrotator" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"[Link]

<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body style="height: 589px">
<form id="form1" runat="server">
<div style="height: 586px">

<asp:AdRotator ID="AdRotator1" runat="server"


AdvertisementFile="~/[Link]" />

</div>
</form>
</body>
</html>
XML file:-
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>[Link]</ImageUrl>
<AlternateText>Greetings</AlternateText>
<NavigationUrl>[Link]</NavigationUrl>
</Ad>

<Ad>
<ImageUrl>[Link]</ImageUrl>
<AlternateText>Good</AlternateText>
<NavigationUrl>SIR ISSAC NEWTON COLLEGE OF ARTS AND SCIENCE</NavigationUrl>
</Ad>

<Ad>
<ImageUrl>[Link]</ImageUrl>
<AlternateText>Nice</AlternateText>
<NavigationUrl>[Link]</NavigationUrl>
</Ad>
</Advertisements>

Common questions

Powered by AI

Using XML Schema Definition (XSD) with XML documents, as shown in the 'student' XML data, allows for defining the structure and data types of XML elements. This ensures data integrity by enforcing rules such as the sequence of elements, types (e.g., string or integer), and constraints (e.g., minOccurs, maxOccurs for collections). In the provided 'student' data, XSD defines elements like 'rollno', 'name', and 'major', which helps in validating XML documents against this schema to ensure compatibility and correctness of the data structure .

The integration of XML and XSLT in the educational system's document structure facilitates transforming XML data into a user-friendly HTML format. XML stores structured data about subjects, while the XSLT stylesheet applies transformations to iterate over XML nodes, extracting data to present in a styled table format. This separation of data content (XML) and presentation logic (XSLT) enhances maintainability and adaptability, allowing changes in presentation style without altering the underlying data. It also promotes consistency in data presentation across different platforms or interfaces, significantly enhancing user experience .

In the provided XML document, styling is applied using an XSL stylesheet referenced in the XML declaration. The XML file (e.g., xmlcs.xml) includes a processing instruction specifying 'xslcs.xsl' as the stylesheet. The XSL stylesheet contains templates for transforming XML data into HTML format, including an HTML table structure that lists subject details by iterating over XML nodes using xsl:for-each. This setup allows dynamic presentation of XML data in a styled HTML layout .

Allowances and deductions in the JSP page EMPLOYEE SALARY BILL are calculated as percentages of the basic salary. These calculations are performed on form submission using embedded Java Scriptlets. Allowances (TA, DA, and HRA) are summed up, while deductions (PF and LIC) are deducted from the gross salary to obtain the net salary. This method relies on user's correct input in the form fields for accurate results. Since the calculation occurs on the server after form submission, this ensures that the logic is handled securely, although heavy reliance on correct form inputs can be a point of failure if validation is inadequate .

The Java interface 'IHello' extends the Remote interface, marking it suitable for remote method invocation. It defines the method 'getGreetingMessage', which any implementing class must provide. As part of the RMI setup, 'IHello' ensures that any object binding to it remotely can be accessed and invoked by clients. This provides a contract that guarantees the communication structure between clients and the remote server, facilitating modularity and decoupled system architecture by allowing remote method execution in the distributed system .

In the RMI application, when the client fails to connect to the server, a ConnectException is thrown. This is caught in a try-catch block, and the client application responds by printing 'Unable to connect to server!' and then exits the program with System.exit(1). This structured handling ensures that specific exceptions related to connectivity are addressed distinctly from other exceptions, which are caught generally by another catch for Exception .

The distributed architecture using RMI enhances fault tolerance by isolating failures to individual components, such as a server or network segment, without necessarily disrupting the entire system. Its scalable nature allows server resources to be distributed across different nodes, which can be easily expanded or replaced. RMI also supports load balancing, as multiple requests can be handled by distributed objects on various servers. By defining interfaces like 'IHello', RMI ensures clear communication contracts, which makes replacing or replicating server objects easier, contributing to robust, scalable network applications .

The SQL operations in the example run typical CRUD operations (Create, Read, Update, Delete) on a 'marksheet' database. 'Create' is handled by inserting new records using INSERT statements, while 'Read' operations could be implied by obtaining data, albeit not explicitly shown or are shown partially through select statements. 'Update' is facilitated through UPDATE queries that modify existing records based on conditions like roll number, and 'Delete' operations manage record removal using DELETE statements. These operations enable comprehensive data manipulation and management in relational databases, exemplified by their usage in educational contexts for managing students' marks .

The Ad Rotator Control in ASP.NET facilitates dynamic advertisement rotation on a web page, as exemplified by the provided setup, which uses an XML file to store advertisement data. Advantages include ease of integration, straightforward management of ad content updates via a centralized XML file, and support for alternate texts and navigation links. However, disadvantages include potential performance overhead when handling large XML files, lack of sophisticated targeting features, and reliance on client-side script execution which might be disabled by users' browsers. Overall, it provides a simple yet limited solution for ad rotation .

The Employee Salary Statement JSP page processes input data from an HTML form, which collects employee details such as name, basic salary, and percentage values for allowances (TA, DA, HRA) and deductions (PF, LIC). Upon submission, the input values are retrieved via request.getParameter and converted into appropriate data types. Calculations for allowances, gross salary, and net salary are performed using embedded Java code blocks (scriptlets). The page dynamically generates and outputs the salary statement as a formatted HTML table. This method tightly integrates presentation with business logic, allowing for immediate feedback .

You might also like