0% found this document useful (0 votes)
33 views

DT_LAB_PROGRAM

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)
33 views

DT_LAB_PROGRAM

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
You are on page 1/ 23

SIR ISSAC NEWTON COLLEGE OF ARTS AND SCIENCE

I M.Sc. Computer Science

DISTRIBUTED TECHNOLOGIES(P22CSCC2AP)

Page
S.No. 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: IHello.java

import java.rmi.*;

public interface IHello extends Remote


{
public String getGreetingMessage() throws RemoteException;
}

File: HelloClientComponent.java

import java.rmi.*;

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) Naming.lookup("rmi://"
+ host + "/Hello");

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


//object method.
System.out.println("Message received: " +
greeting_message.getGreetingMessage());
}
catch (ConnectException conEx)
{
System.out.println("Unable to connect to server!");
System.exit(1);
}
catch (Exception ex)
{
ex.printStackTrace();
System.exit(1);
}
}
}
File: HelloImplementation.java

import java.rmi.*;
import java.rmi.server.*;

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: HelloServerComponent.java

import java.rmi.*;

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.
Naming.rebind(rmiObjectName, temp);

//Step 4
//Tell to the user that the process is completed.
System.out.println("Binding complete...\n");
}
}
WEB PAGES USING JSP SCRIPTLET
File: emp.html

<html>
<head>
<title>Employee Salary Statement</title>
</head>
<body bgcolor="wheat">
<center>
<h3>Enter Employee Details:<h3>
<form action="empsalary.jsp" 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: empsalary.jsp

<html>
<head>
<title>Employee Salary Bill </title>
</head>
<body bgcolor="gold">
<%
String ename=request.getParameter("ename");
double bsal=Double.valueOf(request.getParameter("bsal"));
double ta=Double.valueOf(request.getParameter("ta"));
double ta2=bsal*ta/100;
double da=Double.valueOf(request.getParameter("da"));
double da2=bsal*da/100;
double hra=Double.valueOf(request.getParameter("hra"));
double hra2=bsal*hra/100;
double pf=Double.valueOf(request.getParameter("pf"));
double pf2=bsal*pf/100;
double lic=Double.valueOf(request.getParameter("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: xmlcs.xml

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


<?xml-stylesheet type="text/xsl" href="xslcs.xsl"?>
<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: xslcs.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:template match="/">
<html>
<body>
<h2>I M.Sc., 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: student.xml

<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: student.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<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 System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page


{

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);
cn.Open();

txtrno.Focus();
lbltotal.Visible = false;
lblavg.Visible = false;
lblmsg.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
int m1 = Convert.ToInt32(TextBox1.Text);
int m2 = Convert.ToInt32(TextBox2.Text);
int m3 = Convert.ToInt32(TextBox3.Text);
int m4 = Convert.ToInt32(TextBox4.Text);
int m5 = Convert.ToInt32(TextBox5.Text);
int tot = m1 + m2 + m3 + m4 + m5;
lbltotal.Visible = true;
lblavg.Visible = true;
lbltotal.Text = tot.ToString();
int percentage = tot / 5;
lblavg.Text = percentage.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
qry = "insert into mark values('" + txtrno.Text + "','" + txtname.Text + "','" + lbltotal.Text +
"')";
cmd = new SqlCommand(qry, cn);
cmd.ExecuteNonQuery();
lbltotal.Visible = true;
lblavg.Visible = true;
lblmsg.Visible = true;
lblmsg.Text = "Record is Inserted";

protected void Button3_Click(object sender, EventArgs e)


{
qry = "update mark set rno='" + txtrno.Text + "', name='" + txtname.Text + "' where rno='"
+ txtrno.Text + "'";
cmd = new SqlCommand(qry, cn);
cmd.ExecuteNonQuery();
lblmsg.Visible = true;
lblmsg.Text = "Record is Updated";
}
protected void Button4_Click(object sender, EventArgs e)
{
qry = "delete from mark where rno='" + txtrno.Text + "'";
cmd = new SqlCommand(qry, cn);
cmd.ExecuteNonQuery();
lblmsg.Visible = true;
lblmsg.Text = "Record is Deleted";

}
protected void Button5_Click(object sender, EventArgs e)
{
txtrno.Text = "";
txtname.Text = "";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";

}
}
VIEWING RECORDS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.Visible = false;
FormView1.Visible = false;
DetailsView1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
FormView1.Visible = true;
}
protected void Button3_Click(object sender, EventArgs e)
{
DetailsView1.Visible = true;
}
}
Grid View:

Form View:
Details View

AD ROTATOR CONTROL
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="mgadrotator.aspx.cs" Inherits="mgadrotator" %>

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


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<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="~/XMLFile.xml" />

</div>
</form>
</body>
</html>
XML file:-
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>11.jpg</ImageUrl>
<AlternateText>Greetings</AlternateText>
<NavigationUrl>www.bdu.ac.in</NavigationUrl>
</Ad>

<Ad>
<ImageUrl>12.jpg</ImageUrl>
<AlternateText>Good</AlternateText>
<NavigationUrl>SIR ISSAC NEWTON COLLEGE OF ARTS AND SCIENCE</NavigationUrl>
</Ad>

<Ad>
<ImageUrl>13.jpg</ImageUrl>
<AlternateText>Nice</AlternateText>
<NavigationUrl>www.google.co.in</NavigationUrl>
</Ad>
</Advertisements>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy