Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Basic HTML, Image: My First Image Is HTML Picture

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 70

Name – Shelton Nazareth

Class –SE IT B
Batch – 2
Roll No. – 36

Aim - Write a code to implement Basic HTML, Formatting and Fonts, Commenting Code, Anchors, Backgrounds,
images, Hyperlinks.

Basic Html, Image

<html>
<head>
<title>Basic HTML</title>
<h1>Header 1</h1>
<h2>Header 2</h2>
<h3>Header 3</h3>
<h4>Header 4</h4>
<h5>Header 5</h5>
<h6>Header 6</h6>
<div>difference between p tag and div tag</div>
<p>difference between p tag and div tag</p><br>
my first image<img src="html.jpg" alt="Pulpit rock" width="304" height="228" /> is html picture

<pre>

Text in a pre element


is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>
</head>
</html>

OUTPUT
Formatting and Fonts

<html>
<body>
<p><font size="2" color="blue">This is some text! using font tag,size attribute,color attribute</font></p>
<p><font face="verdana" color="green">This is some text!using font tag,face attribute,color attribute</font></p>
<b>This text is bold</b><br>
<strong>This text is strong</strong><br>
<big>This text is big</big><br>
<small>Small text</small><br>
<i>This text is italic</i><br>
<em>This text is emphasized</em><br>
<code>This is computer output</code><br>
This is<sub> subscript</sub> and <sup>superscript</sup><br>
My favorite color is <del>blue</del> <ins>red</ins>!<br>
<p>Notice that browsers will strikethrough deleted text and underline inserted text.</p>
<dfn>Definition term</dfn><br>
<samp>Sample computer code text</samp><br>
<kbd>Keyboard text</kbd><br>
<var>Variable</var><br>
<cite>Citation</cite><br>
The <abbr title="World Health Organization">WHO</abbr> was founded in 1948<br>
Can I get this <acronym title="as soon as possible">ASAP</acronym>?<br>
<tt>Teletype text</tt><br>
<address>
my address<br />
is in<br />
so n so place<br />
at so n so area
</address><br>
<bdo dir="rtl">Here is some Hebrew text that should be written from right-to-left!</bdo><!bidirectional override!
><br>
<blockquote>
Here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long
quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation.
</blockquote><br>
<q>
Here is a short quotation here is a short quotation
</q><br>
</body>
</html>
OUTPUT
Commenting Code
<html>
<body>

<!--This is a comment. Comments are not displayed in the browser-->


<p>This is a paragraph.</p>

</body>
</html>

OUTPUT

Anchors, Hyperlink
<html>
<body>

<a href="#top" name ="top">TOP</a>


<a href="#bottom">BOTTOM</a><br>

<a href="http://www.google.com/">Visit google</a><br>


<a href="http://www.yahoo.com/">Visit yahoo</a><br>

<p>Open link in a new window or tab: <a href="http://www.facebook.com/" target="_blank">Visit


Facebook</a></p

<p>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2><a >Chapter 4</a></h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 10</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 11</h2>
<p>This chapter explains ba bla bla</p><br>

<a href="#top" >TOP</a>


<a href="#bottom" name ="bottom">BOTTOM</a>

</body>
</html>
OUTPUT
Background
<html>
<head>
<title>Text</title>
<body background="Background.jpg">
</body>
</head>

OUTPUT
Name – Shelton Nazareth
Class –SE IT B
Batch – 2
Roll No. – 36

Aim - Write a HTML code to implement class timetable and three different type of list.

Timetable

<html>
<head>
<title>SE IT B timetable</title>
</head>
<body>
<font face="Century Gothic" size=4">
<table border = "3" bordercolor="black" cellpadding="5">
<caption><b><u>SE IT B timetable</u></b></caption>
<tr>
<td align="center"><b><u>D & T</b></u></td>
<td align="center" colspan = "3"><u><b>Monday</b></u></td>
<td align="center" colspan = "3"><b><u>Tuesday</u></b></td>
<td align="center" ><b><u>Wednesday</u></td>
<td align="center" colspan = "3"><b><u>Thursday</u></td>
<td align="center" colspan = "3"><b><u>Friday</u></td>
</tr>
<tr>
<td align="center">8 - 9</td>
<td align="center" rowspan = "2"><font color="red">IP Prac's</font></td>
<td align="center" rowspan = "2"><font color="blue">CM Prac's</font></td>
<td align="center" rowspan = "2"><font color="green">NTDD Prac's</font></td>
<td align="center" rowspan = "2"><font color="red">IP Prac's</font></td>
<td align="center" rowspan = "2"><font color="blue">NTDD Prac's</font></td>
<td align="center" rowspan = "2"><font color="green">PCOM Prac's</font></td>
<td align="center" >CM Lec</td>
<td align="center" rowspan = "2"><font color="red">CM Prac's</font></td>
<td align="center" rowspan = "2"><font color="blue">PCOM Prac's</font></td>
<td align="center" rowspan = "2"><font color="green">IP Prac's</font></td>
<td align="center" colspan="3" > PCOM Lec</td>
</tr>
<tr>
<td align="center">9 - 10</td>
<td align="center" >FAMT Lec</td>
<td align="center" colspan="3">IP Lec</td>
<tr>
<td align="center">10 - 10:15</td>
<td align="center" colspan="13"><b><u>Tea Break</b></u><td>
</tr>
<tr>
<td align="center" >10:15 - 11:15</td>
<td align="center" colspan="3">FAMT Lec</td>
<td align="center" colspan="3">CM Lec</td>
<td align="center">PCOM Lec</td>
<td align="center" colspan="3">NTDD Lec</td>
<td align="center" colspan="3">MPMC Lec</td>
</tr>
<td align="center" >11:15 - 12:15</td>
<td align="center" colspan="3">PCOM Lec</td>
<td align="center" colspan="3">FAMT Lec</td>
<td align="center">NTDD Lec</td>
<td align="center" colspan="3">CM Lec</td>
<td align="center" colspan="3">NTDD Lec</td>
</tr>
<tr>
<td align="center">12:15 - 1</td>
<td align="center" colspan="13"><b><u>Lunch Break</u></b><td>
</tr>
<tr>
<td align="center">1 - 2</td>
<td align="center" colspan="3">MPMC Lec</td>
<td align="center" rowspan="2"><font color="red">PCOM Prac's</font></td>
<td align="center" rowspan="2"><font color="blue">IP Prac's</font></td>
<td align="center" rowspan="2"><font color="green">CM Prac's</font></td>
<td align="center">MPMC Lec</td>
<td align="center" colspan="3">PCOM Lec</td>
<td align="center" rowspan="2"><font color="red">NTDD Prac's</font></td>
<td align="center" rowspan="2"><font color="blue">IP Prac's</font></td>
<td align="center" rowspan="2"><font color="green">PCOM Prac's</font></td>
</tr>
<tr>
<td align="center">2 - 3</td>
<td align="center" colspan="3">NTDD Lec</td>
<td align="center">IP Lec</td>
<td align="center" colspan="3">FAMT Lec</td>
</tr>
<tr>
<td align="center">3 - 4</td>
<td align="center" rowspan="2"><font color="red">MPMC Prac's</font></td>
<td align="center"><font color="blue">FAMT tuts</font></td>
<td align="center" rowspan="2"><font color="green">IP Prac's</font></td>
<td align="center" colspan="3">MPMC Lec</td>
<td align="center" rowspan="2">free slot</td>
<td align="center" rowspan="2">free slot</td>
<td align="center" rowspan="2"><font color="blue">MPMC Prac's</font></td>
<td align="center" ><font color="green">FAMT tuts</font></td>
<td align="center" colspan="3">CM Lec</td>
</tr>
<tr>
<td align="center">4 - 5</td>
<td align="center" >free slot</td>
<td align="center" colspan="3">free slot</td>
<td align="center">free slot</td>
<td align="center"><font color="red">FAMT tuts</font></td>
<td align="center">free slot</td>
<td align="center">free slot</td>
</tr>
</table>
<p><font color="red"><b>Red=batch 1</b></font><br/><font color="blue"><b>Blue=batch 2</b></font><br/><font
color="green"><b>Green=batch 3</b></font><br/><b>Black=for full class</b></p>

OUTPUT

LIST

Unordered list

<html>
<head>
<title>lists</title>
</head>
<body>
<H2>Types of unordered lists</h2>
<h4>Disc bullets list:</h4>
<ul type="disc">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Circle bullets list:</h4>
<ul type="circle">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Square bullets list:</h4>
<ul type="square">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
</body>
</html>
Output
Ordered list

<H2>Types of ordered lists</h2>


<h4>Numbered list:</h4>
<ol>
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Letters list:</h4>
<ol type="A">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Lowercase letters list:</h4>
<ol type="a">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Roman numbers list:</h4>
<ol type="I">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Lowercase Roman numbers list:</h4>
<ol type="i">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>

Output

Nested list
<h4>A nested List:</h4>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>

Output

Definition list
<h4>DEFINITION LIST</H4>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>

Output

Name – Shelton Nazareth


Class –SE IT B
Batch – 2
Roll No. – 36

Aim - Write a HTML code to implement forms and frames.(include text, password, radio, checkbox,
dropdown(select),button in form)

MAIN.HTML
<html>
<head>
<title>site</title>
</head>
<frameset rows="35%,65%">
<frame src="3.html" name="top">
<frameset cols="20%,80%">
<frame src="4.html" name="left">
<frame src="`.html" name="right">
</frameset>
</frameset>
</html>
<html>
<head>
<title>
Departments
</title>
<dl>
<dt>-IT Dept.</dt>
<dd>-->Na</dd>
<dt>-Computer Dept.</dt>
<dd>-->NA</dd>
<dt>-EXTC Dept.</dt>
<dd>-->NA</dd>
</dl>
</body>
</html>

<html>
<head>
<title>resume</title>
</head>
<body>
<font face="Century Gothic" size="2">
<center><u><big><b>RESUME</b></u></big></center>
<form>
<table width="900" border="4" cellspacing="10" cellpadding="10">
<tr><td><u>Name: </u></td>
<td> <input type="text"></td><br>
</tr>
<tr>
<td><u>Address:<u></td>
<td><textarea rows="3"
columns="1"
wrap=virtual></textarea></td>
</tr>
<tr>
<td><u>Password:</u></td>
<td><input type="password"></td>
</tr>
<tr>
<td><u>Gender</u></td>
<td><input type="radio" Name=a>Male</radio></td>
<td><input type="radio" Name=a>Female</radio></td>
</tr>
<tr>
<td><u>Qualifications:</u></td>
<td><input type="checkbox">SSC </td>
<td><input type="checkbox">HSC</td>
<td><input type="checkbox">DIPLOMA</td>
<td><input type="checkbox">DEGREE</td>
<td><input type="checkbox">MBA</td>
</tr>
<tr>
<td><input type="submit"></td>
<td rowspan="2"><input type="reset"></td>
</tr>
</table>
</form>
</body>
</html>

<html>
<head>
<title>
SFIT File Format
</title>
<body>
<center><font face="Century Gothic" size="2">
<font face="Algerian" size="6"><u>ST FRANCIS INSTITUTE OF TECHNOLOGY</u></font>
<font face="Century Gothic" size="3">
<br><br>ENGINEERING COLLEGE</br>
Mount Poisur, S.V.P Road,Borivali(W),Mumbai-103</br></font>
<br><a href="http://sfitb.webs.com" target="__blank"><img src="sfit.bmp"></a>
<br>
</center>
</body>
</head>
</html>

<html>
<title>hyperlink</title>
<head><body>
<big><a href="3.html" target="right">Home</a><br><br>
<a href="1.html" target="right">Departments</a><br><br>
<a href="2.html" target="right">Resume</a><br><br>
<a href="mailto:sfit.it@gmail.com? Subject=Site Check & body=******">Contact us</a>
</body>
</head>
</html>

Name – Shelton Nazareth


Class –SE IT B
Batch – 2
Roll No. – 36

Aim - Write a code to implement CSS.


I. 3 types of selectors
II. 3 css level 
III. properties(text,font,background,image,table,link,list,padding,margin,positioning,Z-Index)

3 types of selectors

ID selector
<html>
<head>
<style type="text/css">
#para1
{
text-align:center;
color:red;
}
</style>
</head>

<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>

OUTPUT
Class Selector

<html>
<head>
<style type="text/css">
.center
{
text-align:center;
}
</style>
</head>

<body>
<h1 class="center">Center-aligned heading</h1>
<h1>Not Affected</h1>
<p class="center">Center-aligned paragraph.</p>
<p>Not Affected</p>
</body>
</html>

OUTPUT
Tag selector

<html>
<head>
<style type="text/css">
b{font-family:arial;font-size:34px;color:blue;text-decoration:underline;}
</style>
</head>
<body>
<b>This is tag selector</b>
</body>
</html>

OUTPUT
3 css level 

Inline style

<html>
<head>
</head>
<body>
<h2 style="color:green;text-decoration:underline;">Introduction</h2>
<i style="font-size:16px;color:blue;">History, Web System, Architecture, URL, DNS</i>
<h2 style="color:green;text-decoration:underline;">HTML</h2>
<i style="font-size:16px;color:blue;">Basic tags</i>
<h2 style="color:green;text-decoration:underline;">CSS</h2>
<i style="font-size:16px;color:blue;">need, introduction</i>
</body>
</html>

OUTPUT
Internal Style Sheet

<html>
<head>
<style type="text/css">
hr {color:sienna;}
p {margin-left:20px;color:blue;}
body {background-image:url("background.jpg");}
</style>
</head>
<body>
<p>Internal Style Sheet</p>
<hr></hr>
<h2 >Not Affected as no tag defined</h2>

</body>
</html>

OUTPUT
External Style Sheet
(.css)File
h2{color:red;text-decoration:underline;}
i{font-style:oblique;font-size:relative:75%;color:blue;}
(.html)File
<html>
<head>
</head>
<body>
<h2 style="color:blue;text-decoration:underline;">Introduction</h2>
<i style="font-size:16px;color:red;">History, Web System, Architecture, URL, DNS</i>
<h2 style="color:blue;text-decoration:underline;">HTML</h2>
<i style="font-size:16px;color:red;">Basic tags</i>
<h2 style="color:blue;text-decoration:underline;">CSS</h2>
<i style="font-size:16px;color:red;">need, introduction</i>
</body>
</html>

OUTPUT
Properties(text,font,background,image,table,link,list,padding,margin,positioning,Z-Index)

Background

<html>
<head>
</head>
<body>
<p style="background-color:yellow;">This text has a background color applied.</p>
<p style="height:100px;background-image:url(1.jpg);">This text has a background image applied. </p>
<p style="height:100px;background-image:url(1.jpg);background-repeat:no-repeat;">This background image
does not repeat. </p>
<p style="height:100px;background-image:url(1.jpg);background-repeat:no-repeat;background-
position:100px;">This background image is positioned 100 pixels in from the left. </p>
<p style="height:100px;width:150px;overflow:scroll;background-image:url(1.jpg);background-
attachment:fixed;">This background image is fixed- it doesn't scroll with its outer container.
random text
random text</p>
</body>
</html>

OUTPUT
Font

<html>
<head>
</head>
<body>
<p style="font-family:georgia;">This text is rendered in georgia.</p>
<p style="font-size:20px;">This text is using a font size of 20 pixels.</p>
<p style="font-style:italic;">This text is in italics.</p>
<p style="font-weight:bold;">This text is bold.</p>
<p style="font-variant:small-caps;">This Text Is Using Caps.</p>
<p style="font:italic small-caps bold 20px georgia;">The styles for this text has been specified with the 'font'
shorthand property.</p>
</body>
</html>

OUTPUT

Link

<html>
<head>
<style type="text/css">
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF0000;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}

a:link {background-color:#B2FF99;}
a:visited {background-color:#FFFF85;}
a:hover {background-color:#FF704D;}
a:active {background-color:#FF704D;}
</style>
</head>
<body>
<p><b><a href="default.asp" target="_blank">This is the link,click/hover mouse over to see CSS link stying
effects</a></b></p>
<p><b>Note:</b>hover mouse over link to see color change</p>
<p><b>Note:</b>click on link and see color change after clicking</p>
</body>
</html>

OUTPUT

List

<html>
<head>
<style type="text/css">
ul
{
list-style-image:url('2.jpg');
}
ol.c {list-style-type:upper-roman;}
ol.d {list-style-type:lower-alpha;}
</style>
</head>

<body>
<p>Example of unordered lists with CSS styling:</p>

<ul class="a">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>

<ul class="b">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>

<p>Example of ordered lists:</p>

<ol class="c">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>

<ol class="d">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
</body>
</html>
OUTPUT
Margin, Padding

<html>
<head>
<style type="text/css">
p
{
background-color:yellow;
}
p.padding
{
padding-top:25px;
padding-bottom:25px;
padding-right:50px;
padding-left:50px;
}
p.margin
{
margin-top:20px;
margin-bottom:100px;
margin-right:50px;
margin-left:50px;
}
</style>
</head>

<body>
<p>This is a paragraph with no specified padding.</p>
<p class="padding">This is a paragraph with specified paddings.</p>
<p>This is a paragraph with no specified margins.</p>
<p class="margin">This is a paragraph with specified margins.</p>
</body>

</html>

OUTPUT

Table
<html>
<head>
<style type="text/css">
table
{
border-collapse:collapse;
width:50%
}
table, td, th
{
border:1px solid red;
}
th
{
height:50px;
background-color:yellow;
color:black;
}
td
{
text-align:right;
vertical-align:bottom;
padding:15px;
}

</style>
</head>

<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
OUTPUT

POSITIONING

<html>
<head>
<style type="text/css">
h1{position:absolute;
bottom:150 px;
right:100 px}
p{{position:absolute;
bottom:200 px;
right:100 px}
</style>
</head>
<body>
<h1>This is heading</h1>
<p>This is paragraph</p>
</body>
</html>

OUTPUT
TEXT

<html>
<head>
</head>
<body>

<p style="color:red;">This is CSS text in red</p>

<p style="text-align:right;">This is CSS text aligned to right</p>

<p style="text-indent:50px;">This text is indented by 50 pixels. What this means is that the first line of the
paragraph will be indented by 50 pixels,<br>but the following lines will not be indented.</p>

<p style="letter-spacing:5px;">This is CSS text with letter spacing applied</p>

<p style="word-spacing:50px;">This is CSS text with word spacing applied</p>

<p style="text-decoration:overline;">This text has a line over the top</p>


<p style="text-decoration:line-through;">This text has a line through the middle</p>
<p style="text-decoration:underline;">This text has a line underneath</p>
<a style="text-decoration:none;" a href="/css/properties/css_text-decoration.cfm" >
This hyperlink has no underline</a>

<p style="text-transform:uppercase;">This text has been transformed to uppercase</p>


<p style="text-transform:lowercase;">THIS TEXT HAS BEEN TRANSFORMED TO LOWERCASE</p>
<p style="text-transform:capitalize;">this text has been capitalized.</p>

<p style="text-shadow:4px 4px 8px blue;">If your browser supports the CSS text-shadow property, this text will
have a shadow.</p>

</body>
</html>

OUTPUT
Name – Shelton Nazareth
Class –SE IT B
Batch – 2
Roll No. – 36

Aim Write a code to implement JavaScript.


I. To display string and popup boxes(alert,confirm,prompt)
II. 3 ways(head, body, external)
III. Operators(calculator program)
IV. Function(calculate area program) 
V. Conditional(To display date)
VI. Loop(heading program)
VII. Built-in objects(String, Array, Date, Math, History)
VIII. User defined object
IX. Write a code to implement form validation using Javascript.

DISPLAY STRING

<html>
<body>
<script type="text/javascript">
document.write("<h4>hello</h4><br>");
document.write("<b>bold</b><br>");
document.write("<i>italic</i><br>");
document.write("<u>underline</u><br>");
alert("msg properly displayed")
</script>
</body>
</html>

OUTPUT
POPUP BOXES(ALERT,CONFIRM,PROMPT)

<head>
<script type="text/javascript">
function show_confirm()
{var r=confirm("Press a button!");
if (r==true)
{ alert("You pressed OK!");}
else
{ alert("You pressed Cancel!");}
}
function show_alert()
{
alert("I am an alert box!");
}
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?");
}
}
</script>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" />
<input type="button" onclick="show_confirm()" value="Show a confirm box" />
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
3 ways(head, body, external)

Head

<html><head>
<script type="text/javascript">
function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}
</script>
</head>

<body>

<h1>My First Web Page</h1>

<p id="demo"></p>

<button type="button" onclick="displayDate()">Display Date</button>

</body>

</html>
Body

<html>
<body>

<h1>My First Web Page</h1>

<p id="demo"></p>

<script type="text/javascript">
document.getElementById("demo").innerHTML=Date();
</script>

</body>
</html>
External

external.js
document.write("<h3>The text was written by an external script</h3>");

external_java.html

<html>
<head>
</head>
<body>
<script type="text/javascript" src="external.js">
</script>
<p>
The actual script is in an external script file called "external.js".
</p>
</body>
</html>

OUTPUT

Operators(calculator program)

<html>
<head><title>Calculator</title>
<script language="javascript">
var inputstring=" "
function updatestring(value)
{
inputstring += value;
document.calculator.input.value=inputstring;
}
</script>
</head>
<body>
<center>
<h1>Calculator</h1>

<form name="calculator">
<table border=5 bordercolor=blue>
<tr><td>

<input type="text" name="input" maxlength=15 size=27><br />


<input type="button" value=" clear " onclick="input.value=' ';inputstring=' ' ">
<input type="button" value=" mod " onclick="updatestring('%')">
<input type="button" value=" * " onclick="updatestring('*')"><br />
<input type="button" value=" 7 " onclick="updatestring('7')">
<input type="button" value=" 8 " onclick="updatestring('8')">
<input type="button" value=" 9 " onclick="updatestring('9')">
<input type="button" value=" / " onclick="updatestring('/')"><br />
<input type="button" value=" 4 " onclick="updatestring('4')">
<input type="button" value=" 5 " onclick="updatestring('5')">
<input type="button" value=" 6 " onclick="updatestring('6')">
<input type="button" value=" - " onclick="updatestring('-')"><br />
<input type="button" value=" 1 " onclick="updatestring('1')">
<input type="button" value=" 2 " onclick="updatestring('2')">
<input type="button" value=" 3 " onclick="updatestring('3')">
<input type="button" value=" + " onclick="updatestring('+')"><br />
<input type="button" value=" 0 " onclick="updatestring('0')">
<input type="button" value=" 00 " onclick="updatestring('00')">
<input type="button" value=" . " onclick="updatestring('.')">
<input type="button" value=" = " onclick="input.value=eval(inputstring);">

</td></tr>

</table>
</form>
</body>

OUTPUT
Function(calculate area program) 

<html>
<head>

<script type="text/javascript">
function area(r)
{
return Math.PI * Math.pow(r,2);
}
</script>

</head>

<body>

<script type="text/javascript">
var r=prompt('Please enter the radius of the circle: ');

document.write("The area of the circle is : "+area(r));


</script>

</body>
</html>

OUTPUT
Conditional(To display date)

<body>
<script type="text/javascript">
var d=new Date();
var theDay=d.getDay();
document.write(d+"<br>");
document.write(theDay+"<br>");
switch (theDay)
{
case 0:
document.write("Sunday");
break;
case 1:
document.write("monday");
break;
case 2:
document.write("tuesday");
break;
case 3:
document.write("wednesday");
break;
case 4:
document.write("thursday");
break;
case 5:
document.write("Friday");
break;
case 6:
document.write("Saturday");
break;
default:
document.write("weekend!");
}
</script>
</body>

Loop(heading program)

<body>
<script type="text/javascript">
for(i=1;i<=6;i++)
{document.write("<h"+i+">Heading"+i+"</h"+i+">");}
</script>

OUTPUT
Built-in objects(String, Array, Date, Math, History)

STRING
<html>
<body>

<script type="text/javascript">

var txt = "This is the text!";

document.write(txt.length + "<br />");

document.write(txt.toLowerCase() + "<br />");


document.write(txt.toUpperCase() + "<br />");

document.write(txt.match("This") + "<br />");


document.write(txt.match("THE") + "<br />");
document.write(txt.match("teext") + "<br />");
document.write(txt.match("text") + "<br />");

document.write(txt.replace("the"," replaced") + "<br />");

document.write(txt.indexOf("T") + "<br />");


document.write(txt.indexOf("THE") + "<br />");
document.write(txt.indexOf("text"));
</script>

</body>
</html>

OUTPUT

Array

<html>
<body>

<script type="text/javascript">
var i;
var myhobbies = new Array();
myhobbies[0] = "Sports";
myhobbies[1] = "Reading";
myhobbies[2] = "Dancing";

for (i=0;i<myhobbies.length;i++)
{
document.write(myhobbies[i] + "<br />");
}
</script>

</body>
</html>

OUTPUT

Date

<html>
<body>

<script type="text/javascript">

var d=new Date();

document.write(d + "<br />");

document.write(d.getFullYear() + "<br />");

document.write(d.getTime() + " milliseconds since 1970/01/01" + "<br />");

var weekday=new Array(7);


weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
document.write("Today is " + weekday[d.getDay()] + "<br />");

document.write("To string (universal time): ");


document.write(d.toUTCString() + "<br />");

d.setFullYear(1992,10,3);
document.write(d + "<br />");

function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}

</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>

OUTPUT
Math

<html>
<body>

<script type="text/javascript">

document.write(Math.round(0.60) + "<br />");


document.write(Math.round(0.50) + "<br />");
document.write(Math.round(0.49) + "<br />");
document.write(Math.round(-4.40) + "<br />");
document.write(Math.round(-4.60) + "<br />");

//return a random number between 0 and 1


document.write(Math.random() + "<br />");
//return a random integer between 0 and 10
document.write(Math.floor(Math.random()*11) + "<br />");

document.write(Math.max(0,150,30,20,38) + "<br />");


document.write(Math.max(-5,-10) + "<br />");
document.write(Math.max(1.5,2.5) + "<br />");

document.write(Math.min(-5,10) + "<br />");


document.write(Math.min(-5,-10) + "<br />");

</script>

</body>
</html>

OUTPUT
History

<html>
<head>
<script type="text/javascript">
function goBack()
{
window.history.back()
}
function goForward()
{
window.history.forward()
}
function goBack()
{
window.history.go(-2)
}
document.write("Number of URLs in history list: " + history.length);
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()" />
<input type="button" value="Go back 2 pages" onclick="goBack()" />
<input type="button" value="Forward" onclick="goForward()" />
</body>
</html>

OUTPUT

User defined object

<html>
<body>

<script type="text/javascript">
carObj={name:"Ferrari",cost:"2 crore",owner:"Shelton",color:"Black"}

document.write(" The " +carObj.color + " " + carObj.name + " belongs to" + " " + carObj.owner);
</script>

</body>
</html>

OUTPUT
Write a code to implement form validation using Javascript.

<html>
<head>
<script type="text/javascript">
function validateForm()
{
alert("hi")

if (document.myForm.fname.value==null || document.forms["myForm"]["fname"].value=="")
{
alert("First name must be filled out");
return false;
}
if (document.myForm.Age.value==null || document.forms["myForm"]["Age"].value=="")
{
alert("Age must be filled out");
return false;
}

if (document.forms["myForm"]["Address"].value==null || document.forms["myForm"]["Address"].value=="")
{
alert("Address must be filled out");
return false;
}
if (document.forms["myForm"]["email"].value==null || document.forms["myForm"]["email"].value=="")
{
alert("E must be filled out");
return false;
}
if (document.forms["myForm"]["email"].value!=null)
{
var x=document.forms["myForm"]["email"].value
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
return true;
}
</script>
</head>
<body>

OUTPUT

Name – Shelton Nazareth


Class –SE IT B
Batch – 2
Roll No. – 36

Aim - Write a code to implement JDBC.

import java.sql.*;

public class JDBCAccessDemo


{
public static void main(String args[])
throws SQLException,ClassNotFoundException
{
String driverClassName="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:myme";

String query = "insert into rollname values (10,'Khan')";


//Load driver class
Class.forName(driverClassName);
// Obtain a connection
Connection con=DriverManager.getConnection(url,"","");
// Obtain a Statement
Statement st=con.createStatement();
//Execute the Query
int count=st.executeUpdate(query);
System.out.println("Rows Effected by this query = "+count);
con.close();
}//main
}//class

/output
C:\jdk1.3\bin>javac JDBCAccessDemo.java

C:\jdk1.3\bin>java JDBCAccessDemo
Rows Effected by this query = 1

C:\jdk1.3\bin>

Name – Shelton Nazareth


Class – SE IT B Batch – 2
Roll No. – 36

CORBA case study

About

The Common Object Request Broker Architecture (CORBA) is a


standard defined by the Object Management Group (OMG) that
enables software components written in multiple computer
languages and running on multiple computers to work together
(i.e., it supports multiple platforms).

CORBA is useful because it enables separate pieces of software written in different


languages and running on different computers to work with each other like a single
application or set of services. More specifically, CORBA is a mechanism in software
for normalizing the method-call semantics between application objects residing
either in the same address space (application) or remote address space (same host,
or remote host on a network). Version 1.0 was released in October 1991. CORBA
uses an interface definition language (IDL) to specify the interfaces which objects
present to the outer world. CORBA then specifies a mapping from IDL to a specific
implementation language like C++ or Java. Standard mappings exist for Ada, C, C+
+, Lisp, Ruby, Smalltalk, Java, COBOL, PL/I and Python. There are also non-
standard mappings for Perl, Visual Basic, Erlang, and Tcl implemented by object
request brokers (ORBs) written for those languages.

The CORBA specification dictates there shall be an ORB through which an


application would interact with other objects. In practice, the application simply
initializes the ORB, and accesses an internal Object Adapter, which maintains things
like reference counting, object (and reference) instantiation policies, and object
lifetime policies. The Object Adapter is used to register instances of the generated
code classes. Generated code classes are the result of compiling the user IDL code,
which translates the high-level interface definition into an OS- and language-specific
class base for use by the user application. This step is necessary in order to enforce
CORBA semantics and provide a clean user process for interfacing with the CORBA
infrastructure.
Some IDL language mappings are more difficult to use than others. For example,
due to the nature of Java, the IDL-Java mapping is rather straightforward and
makes usage of CORBA very simple in a Java application. This is also true of the IDL
to Python mapping. The C++ mapping is notoriously difficult; the mapping requires
the programmer to learn complex and confusing datatypes that predate the C++
Standard Template Library (STL). Since the C language is not object-oriented, the
IDL to C mapping requires a C programmer to manually emulate object-oriented
features.

A language mapping requires the developer to create IDL code that represents the
interfaces to his objects. Typically, a CORBA implementation comes with a tool
called an IDL compiler which converts the user's IDL code into some language-
specific generated code. A traditional compiler then compiles the generated code to
create the linkable-object files for the application. This diagram illustrates how the
generated code is used within the CORBA infrastructure:

Illustration of the autogeneration of the infrastructure code from an interface


defined using the CORBA IDL

This figure illustrates the high-level paradigm for remote interprocess


communications using CORBA. Issues not addressed here, yet accounted for in the
CORBA specification, include data typing, exceptions, network protocols,
communication timeouts, etc. For example: Normally the server side has the
Portable Object Adapter (POA) that redirects calls either to the local servants or (to
balance the load) to the other servers. Also, both server and client parts often have
interceptors that are described below. Issues CORBA (and thus this figure) does not
address, but that all distributed systems must address, include object lifetimes,
redundancy/fail-over, naming semantics (beyond a simple name), memory
management, dynamic load balancing, separation of model between
display/data/control semantics, etc.

In addition to providing users with a language and a platform-neutral remote


procedure call (RPC) specification, CORBA defines commonly needed services such as transactions and security,
events, time, and other domain-specific interface models.

OMG trademarks
CORBA, IIOP and OMG are the registered marks of the Object Management
Group and should be used with care. However, GIOP (General Inter-ORB
Protocol) is not a registered OMG trademark. Hence in some cases it may be
more appropriate just to say that the application uses or implements the
GIOP-based architecture.

Objects By Reference

This reference is either acquired through a stringified Uniform Resource Identifier


(URI) string, NameService lookup (similar to Domain Name System (DNS)), or
passed-in as a method parameter during a call.

Object references are lightweight objects matching the interface of the real object
(remote or local). Method calls on the reference result in subsequent calls to the
ORB and blocking on the thread while waiting for a reply, success or failure. The
parameters, return data (if any), and exception data are marshaled internally by
the ORB according to the local language and OS mapping.

Data By Value

The CORBA Interface Definition Language provides the language- and OS-neutral
inter-object communication definition. CORBA Objects are passed by reference,
while data (integers, doubles, structs, enums, etc.) are passed by value. The
combination of Objects by reference and data-by-value provides the means to
enforce strong data typing while compiling clients and servers, yet preserve the
flexibility inherent in the CORBA problem-space.

Objects By Value (OBV)

Apart from remote objects, the CORBA and RMI-IIOP define the concept of the OBV
and Valuetypes. The code inside the methods of Valuetype objects is executed
locally by default. If the OBV has been received from the remote side, the needed
code must be either a priori known for both sides or dynamically downloaded from
the sender. To make this possible, the record, defining OBV, contains the Code Base
that is a space-separated list of URLs from where this code should be downloaded.
The OBV can also have the remote methods.

The OBVs may have fields that are transferred when the OBVs are transferred.
These fields can be OBVs themselves, forming lists, trees or arbitrary graphs. The
OBVs have a class hierarchy, including multiple inheritance and abstract classes.

CORBA Component Model (CCM)

CORBA Component Model (CCM) is an addition to the family of CORBA definitions. It


was introduced with CORBA 3 and it describes a standard application framework for
CORBA components. Though not dependent on "language independent Enterprise
Java Beans (EJB)", it is a more general form of EJB, providing four component types
instead of the two that EJB defines. It provides an abstraction of entities that can
provide and accept services through well-defined named interfaces called ports.

The CCM has a component container, where software components can be deployed.
The container offers a set of services that the components can use. These services
include (but are not limited to) notification, authentication, persistence and
transaction processing. These are the most-used services any distributed system
requires, and, by moving the implementation of these services from the software
components to the component container, the complexity of the components is
dramatically reduced.

Portable interceptors

Portable interceptors are the "hooks", used by CORBA and RMI-IIOP to mediate the
most important functions of the CORBA system. The CORBA standard defines the
following types of interceptors:

1. IOR interceptors mediate the creation of the new references to the remote
objects, presented by the current server.
2. Client interceptors usually mediate the remote method calls on the client
(caller) side. If the object Servant exists on the same server where the
method is invoked, they also mediate the local calls.
3. Server interceptors mediate the handling of the remote method calls on the
server (handler) side.

The interceptors can attach the specific information to the messages being sent and
IORs being created. This information can be later read by the corresponding
interceptor on the remote side. Interceptors can also throw forwarding exceptions,
redirecting request to another target.

General InterORB Protocol (GIOP)

Main article: General Inter-ORB Protocol

The GIOP is an abstract protocol by which Object request brokers (ORBs)


communicate. Standards associated with the protocol are maintained by the Object
Management Group (OMG). The GIOP architecture provides several concrete
protocols, including:

1. Internet InterORB Protocol (IIOP) — The Internet Inter-Orb Protocol is an


implementation of the GIOP for use over the Internet, and provides a mapping
between GIOP messages and the TCP/IP layer.
2. SSL InterORB Protocol (SSLIOP) — SSLIOP is IIOP over SSL, providing
encryption and authentication.
3. HyperText InterORB Protocol (HTIOP) — HTIOP is IIOP over HTTP, providing
transparent proxy bypassing.

VMCID (Vendor Minor Codeset ID)

Each standard CORBA exception includes a minor code to designate the subcategory
of the exception. Minor exception codes are of type unsigned long and consist of a
20-bit “Vendor Minor Codeset ID” (VMCID), which occupies the high order 20 bits,
and the minor code proper which occupies the low order 12 bits.

Minor codes for the standard exceptions are prefaced by the VMCID assigned to
OMG, defined as the unsigned long constant CORBA::OMGVMCID, which has the
VMCID allocated to OMG occupying the high order 20 bits. The minor exception
codes associated with the standard exceptions that are found in Table 3-13 on page
3-58 are or-ed with OMGVMCID to get the minor code value that is returned in the
ex_body structure (see Section 3.17.1, “Standard Exception Definitions,” on page
3-52 and Section 3.17.2, “Standard Minor Exception Codes,” on page 3-58).

Within a vendor assigned space, the assignment of values to minor codes is left to
the vendor. Vendors may request allocation of VMCIDs by sending email to
tagrequest@omg.org.

The VMCID 0 and 0xfffff are reserved for experimental use. The VMCID OMGVMCID
(Section 3.17.1, “Standard Exception Definitions,” on page 3-52) and 1 through 0xf
are reserved for OMG use.

The Common Object Request Broker: Architecture and Specification (CORBA 2.3)

Corba Location (CorbaLoc)


Corba Location (CorbaLoc) refers to a stringified object reference for a CORBA
object that looks similar to a URL.

All CORBA products must support two OMG-defined URLs: "corbaloc:" and
"corbaname:". The purpose of these is to provide a human readable and editable
way to specify a location where an IOR can be obtained.

An example of corbaloc is shown below:

corbaloc::160.45.110.41:38693/StandardNS/NameServer-POA/_root

A CORBA product may optionally support the "http:", "ftp:" and "file:" formats. The
semantics of these is that they provide details of how to download a stringified IOR
(or, recursively, download another URL that will eventually provide a stringified
IOR). Some ORBs do deliver additional formats which are proprietary for that ORB.

Benefits
CORBA aims to bring to the table many benefits that no other single technology
brings in one package. These benefits include language- and OS-independence,
freedom from technology-linked implementations, strong data-typing, high level of
tunability, and freedom from the details of distributed data transfers.

Language Independence
CORBA at the outset was designed to free engineers from the hang-ups and
limitations of considering their designs based on a particular software language.
Currently there are many languages supported by various CORBA providers, the
most popular being Java and C++. There are also C-only, SmallTalk, Perl, Ada,
Ruby, and Python implementations, just to mention a few.

OS Independence
CORBA's design is meant to be OS-independent. CORBA is available in Java (OS-
independent), as well as natively for Linux/Unix, Windows, Sun, Mac and others.

Freedom from Technologies


One of the main implicit benefits is that CORBA provides a neutral playing field for
engineers to be able to normalize the interfaces between various new and legacy
systems. When integrating C, C++, Object Pascal, Java, Fortran, Python, and any
other language or OS into a single cohesive system design model, CORBA provides
the means to level the field and allow disparate teams to develop systems and unit
tests that can later be joined together into a whole system. This does not rule out
the need for basic system engineering decisions, such as threading, timing, object
lifetime, etc. These issues are part of any system regardless of technology. CORBA
allows system elements to be normalized into a single cohesive system model.
For example, the design of a multitier architecture is made simple using Java
Servlets in the web server and various CORBA servers containing the business logic
and wrapping the database accesses. This allows the implementations of the
business logic to change, while the interface changes would need to be handled as
in any other technology. For example, a database wrapped by a server can have its
database schema change for the sake of improved disk usage or performance (or
even whole-scale database vendor change), without affecting the external
interfaces. At the same time, C++ legacy code can talk to C/Fortran legacy code
and Java database code, and can provide data to a web interface.

Strong Data Typing


CORBA provides flexible data typing, for example an "ANY" datatype. CORBA also
enforces tightly coupled datatyping, reducing human errors. In a situation where
Name-Value pairs are passed around, it is conceivable that a server provides a
number where a string was expected. CORBA Interface Definition Language
provides the mechanism to ensure that user-code conforms to method-names,
return-, parameter-types, and exceptions.

High Tune-ability
There are many implementations available (e.g. OmniORB (Open source C++ and
Python implementation)) that have many options for tuning the threading and
connection management features. Not all implementations provide the same
features. This is up to the implementor.

Freedom From Data Transfer Details


When handling low-level connection and threading, CORBA provides a high level of
detail in error conditions. This is defined in the CORBA-defined standard exception
set and the implementation-specific extended exception set. Through the
exceptions, the application can determine if a call failed for reasons such as "Small
problem, so try again", "The server is dead" or "The reference doesn't make sense."
The general rule is: Not receiving an exception means that the method call
completed successfully. This is a very powerful design feature.

Compression
CORBA marshals its data in a binary form and supports compression. IONA,
Remedy IT and Telefónica have worked on an extension to the CORBA standard that
delivers compression. This extension is called ZIOP and this is now a formal OMG
standard.

Problems and criticism


While CORBA promised to deliver much in the way code was written and software
constructed, it has been the subject of much criticism.
Some of the failures were due to the implementations and the process by which
CORBA was created as a standard; others reflect problems in the politics and
business of implementing a software standard. These problems led to a significant
decline in CORBA use and adoption in new projects and areas.

Implementation incompatibilities

The initial specifications of CORBA defined only the IDL, not the on-the-wire format.
This meant that source-code compatibility was the best that was available for
several years.

Location transparency

CORBA's notion of location transparency has been criticized; that is, that objects
residing in the same address space and accessible with a simple function call are
treated the same as objects residing elsewhere (different processes on the same
machine, or different machines). This notion is flawed if one requires all local
accesses to be as complicated as the most complex remote scenario. However,
CORBA does not place a restriction on the complexity of the calls. Many
implementations provide for recursive thread/connection semantics. I.e. Obj A calls
Obj B, which in turn calls Obj A back, before returning.

Design and process deficiencies

The creation of the CORBA standard is also often cited for its process of design by
committee. There was no process to arbitrate between conflicting proposals or to
decide on the hierarchy of problems to tackle. Thus the standard was created by
taking a union of the features in all proposals with no regard to their coherence.
This made the specification very complex, expensive to implement entirely and
often ambiguous.
A design committee composed largely of vendors of the standard implementation,
created a disincentive to make a comprehensive standard. This was because
standards and interoperability increased competition and eased customers'
movement between alternative implementations. This led to much political fighting
within the committee, and frequent releases of revisions of the CORBA standard
that were impossible to use without proprietary extensions.

Problems with implementations

Through its history, CORBA has been plagued by shortcomings in its


implementations. Often there have been few implementations matching all of the
critical elements of the specification, and existing implementations were incomplete
or inadequate. As there were no requirements to provide a reference
implementation, members were free to propose features which were never tested
for usefulness or implementability. Implementations were further hindered by the
general tendency of the standard to be verbose, and the common practice of
compromising by adopting the sum of all submitted proposals, which often created
APIs that were incoherent and difficult to use, even if the individual proposals were
perfectly reasonable.
Working implementations of CORBA have been very difficult to acquire in the past,
but are now much easier to find. The SUN Java SDK comes with CORBA already.
Some poorly designed implementations have been found to be complex, slow,
incompatible and incomplete. Commercial versions can be very expensive. This
changed significantly as commercial-, hobbyist-, and government-funded high
quality free implementations became available.

Firewalls

CORBA (more precisely, IIOP) uses raw TCP/IP connections in order to transmit
data. However, if the client is behind a very restrictive firewall or transparent proxy
server environment that only allows HTTP connections to the outside through port
80, communication may be impossible, unless the proxy server in question allows
the HTTP CONNECT method or SOCKS connections as well. At one time, it was
difficult even to force implementations to use a single standard port — they tended
to pick multiple random ports instead. As of today, current ORBs do have these
deficiencies. Due to such difficulties, some users have made increasing use of web
services instead of CORBA. These communicate using XML/SOAP via port 80, which
is normally left open or filtered through a HTTP proxy inside the organization, for
web browsing via HTTP. Recent CORBA implementations, though, support SSL and
can be easily configured to work on a single port. Most of the popular open source
ORBS, such as TAO and JacORB also support bidirectional GIOP, which gives CORBA
the advantage of being able to use callback communication rather than the polling
approach characteristic of web service implementations. Also, more CORBA-friendly
firewalls are now commercially available.
Name: Shelton Nazareth
Class - SE-INFT-B
Roll no: 36
Batch-2

import java.io.*;
import java.math.*;
import java.util.*;

class BF
{
public static void main(String args[])throws IOException
{
// Initialization
BufferedReader br=new
BufferedReader(new InputStreamReader(System.in));
int di=100,ds=0;
int k,s,t;
int mat[][],i,j,node,root,pl[],tl[],count;
char a,b,m;

// Enter the number of Nodes & create the Graph matrix of size (node,node)

System.out.print("Enter Number of Nodes:");


node=Integer.parseInt(br.readLine());
mat=new int[node][node];

// Enter the path costs inside the Graph matrix

System.out.println("Enter the Path Costs:");


for(i=0,a='A';i<node;i++,a++)
for(j=0,b='A';j<node;j++,b++)
{
System.out.print("for node"+a+"-"+b+":");
mat[i][j]=Integer.parseInt(br.readLine());
}
// Display the Graph matrix

System.out.println("The values are:");

// Horizontal display of Nodes

for(t=0,m='A';t<node;t++)
{
System.out.print("\t"+ m);
m++;
}
System.out.println("\n");
//Vertical Display of Nodes & entries of matrix

for(i=0,a='A';i<node;i++,a++)
{
System.out.print(a);
for(j=0;j<node;j++)
{
System.out.print("\t"+mat[i][j]);
}
System.out.println("\n");
}

// Enter the source node & Initialize the Temporary Array

System.out.println("Select the Source Node(type 0 for A ,1 for B and so on...)");


root=Integer.parseInt(br.readLine());

tl=new int[node];
int wt=0;

// Pickup the required Row of Graph Matrix & store in T.L.

for(i=0;i<node;i++)
tl[i]=mat[root][i];

// Update the Graph Matrix to find the minimum cost

for(j=0;j<node;j++)
{
for(count=1;count<node;count++)
{
for(i=0;i<node;i++)
{
wt=tl[count]+mat[count][i];
tl[i]=Math.min(tl[i],wt);
}

}
}
// Display the optimum path cost from Given source Node

System.out.println("\n"+"The minimum path costs from Given Source Node are:");


for(a='A',i=0;i<node;i++,a++)
System.out.println("\n"+a+"("+tl[i]+")");
}
}

/*OUTPUT:
Enter Number of Nodes:5

Enter the Path Costs:


for nodeA-A:
0
for nodeA-B:
6
for nodeA-C:
99
for nodeA-D:
7
for nodeA-E:
99
for nodeB-A:
99
for nodeB-B:
0
for nodeB-C:
5
for nodeB-D:
8
for nodeB-E:
-4
for nodeC-A:
99
for nodeC-B:
-2
for nodeC-C:
0
for nodeC-D:
99
for nodeC-E:
99
for nodeD-A:
99
for nodeD-B:
99
for nodeD-C:
-3
for nodeD-D:
0
for nodeD-E:
9
for nodeE-A:
2
for nodeE-B:
99
for nodeE-C:
7
for nodeE-D:
99
for nodeE-E:
0
the values are:
A B C D E

A 0 6 99 7 99

B 99 0 5 8 -4

C 99 -2 0 99 99

D 99 99 -3 0 9

E 2 99 7 99 0

Select the Source Node(type 0 for A ,1 for B and so on...)


0

The minimum path costs from Given Source Node are:

A(0)

B(2)

C(4)

D(7)

E(-2)
Name: Shelton Nazareth
Class - SE-INFT-B
Roll no: 36
Batch-2

UDP Client

import java.io.*;
import java.net.*;

class UDPC
{
public static void main (String args[ ]) throws Exception
{
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientSocket = new DatagramSocket( ); //a datagramsocket object is created
InetAddress IPAddress = InetAddress.getByName("192.168.1.45"); //an object of InetAddress
created
byte[ ] sendData = new byte[1024]; //an array of the type btye is created
byte[ ] receiveData = new byte[1024]; //an array of the type btye is created
System.out.println("IP Address:"+IPAddress+"\tPort:"); //ipaddress and port is displayed
System.out.println("Type something and press <Enter>\n");
String sentence = inFromUser.readLine(); //data entered by client
sendData = sentence.getBytes(); //data is stored in sendData
DatagramPacket sendPacket = new DatagramPacket (sendData,sendData.length, IPAddress, 5000);
//specifies a target address and port, which are used by a DatagramSocket to determine where the data in the
packet will be sent
clientSocket.send(sendPacket); //data is being send
System.out.println("Sending line to server...");
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); //reply is
received in datagramPackets
clientSocket.receive(receivePacket);
String modifiedSentence = new String(receivePacket.getData()); //converted into string
System.out.println("FROM SERVER:" + modifiedSentence); //displayed
clientSocket.close(); //client socket is closed
}
}

UDP Server

import java.io.*;
import java.net.*;

class UDPS
{
public static void main (String args[ ]) throws Exception
{
DatagramSocket serverSocket = new DatagramSocket(5000); //a datagramsocket object is created
System.out.println("Waiting for client");
byte[ ] receiveData = new byte[1024]; //an array of the type btye is created
byte[ ] sendData = new byte[1024]; //an array of the type btye is created
while(true)
{
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length); //data is received in datagramPackets
serverSocket.receive(receivePacket);
System.out.println("Got a client");
String sentence = new String(receivePacket.getData());
//converted into string
System.out.println("Client has sent this:"+ sentence); //displayed
InetAddress IPAddress = receivePacket.getAddress(); //an object of InetAddress created
int port = receivePacket.getPort(); //Returns the port number
String capitalizedSentence = sentence.toUpperCase(); //data is capitalised
sendData = capitalizedSentence.getBytes(); //data is stored in sendData
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress,
port); //specifies a target address and port, which are used by a DatagramSocket to determine where the data in
the packet will be sent
System.out.println("Enter to send back:");
System.out.println("Sending it back");
serverSocket.send(sendPacket); //reply is sent
System.out.println("Waiting for next line");
}
}
}

OUTPUT:

Client side:
D:\NOTES\Sem-4\NTDD\UDP>set path=C:\Program Files\Java\jdk1.6.0\bin
D:\NOTES\Sem-4\NTDD\UDP>javac UDPC.java
D:\NOTES\Sem-4\NTDD\UDP>java UDPC
IP Address:/192.168.1.45 Port:5000
Type something and press <Enter>

Hi
Sending line to server...
FROM SERVER:HI
D:\NOTES\Sem-4\NTDD\UDP>java UDPC
IP Address:/192.168.1.45 Port:
Type something and press <Enter>

How r u?
Sending line to server...
FROM SERVER:HOW R U?

D:\NOTES\Sem-4\NTDD\UDP>java UDPC
IP Address:/192.168.1.45 Port:
Type something and press <Enter>

Bye take care!!!


Sending line to server...
FROM SERVER:BYE TAKE CARE!!!

Server side:

D:\NOTES\Sem-4\NTDD\UDP>set path=C:\Program Files\Java\jdk1.6.0\bin

D:\NOTES\Sem-4\NTDD\UDP>javac UDPS.java

D:\NOTES\Sem-4\NTDD\UDP>java UDPS
Waiting for client
Got a client
Client has sent this:Hi
Enter to send back:
Sending it back
Waiting for next line
Got a client
Client has sent this:How r u?

Enter to send back:


Sending it back
Waiting for next line
Got a client
Client has sent this:Bye take care!!!

Enter to send back:


Sending it back
Waiting for next line
Name: Shelton Nazareth
Class - SE-INFT-B
Roll no: 36
Batch-2

Hello.java

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

public class Hello extends UnicastRemoteObject implements HelloInterface {


private String message;
public Hello (String msg) throws RemoteException {
message = msg;
}
public String say() throws RemoteException {
return message;
}
}

HelloClient.java

import java.rmi.Naming;

public class HelloClient


{
public static void main (String[] argv) {
try {
HelloInterface hello =(HelloInterface) Naming.lookup ("//10.10.0.23/Hello");
System.out.println (hello.say());
}
catch (Exception e){
System.out.println ("HelloClient exception: " + e);}
}
}

HelloInterface.java

import java.rmi.*;
public interface HelloInterface extends Remote {
public String say() throws RemoteException;
}

HelloServer.java

import java.rmi.Naming;

public class HelloServer


{
public static void main (String[] argv)
{
try {
Naming.rebind ("Hello", new Hello ("Hello,From Roseindia.net pvt ltd!"));
System.out.println ("Server is connected and ready for operation.");
}
catch (Exception e) {
System.out.println ("Server not connected: " + e);
}
}
}

OUTPUT

1st command promt


-----------------------
C:\Documents and Settings\SFIT>cd C:\Program Files\Java\jdk1.6.0_16\bin

C:\Program Files\Java\jdk1.6.0_16\bin>javac HelloInterface.java

C:\Program Files\Java\jdk1.6.0_16\bin>javac Hello.java

C:\Program Files\Java\jdk1.6.0_16\bin>javac HelloServer.java

C:\Program Files\Java\jdk1.6.0_16\bin>javac HelloClient.java

C:\Program Files\Java\jdk1.6.0_16\bin>rmic Hello

C:\Program Files\Java\jdk1.6.0_16\bin>start rmiregistry

C:\Program Files\Java\jdk1.6.0_16\bin>java HelloServer


Server is connected and ready for operation.

2nd command prompt


-------------------------
C:\Program Files\Java\jdk1.6.0_16\bin>java HelloClient
Hello,From Roseindia.net pvt ltd!

C:\Program Files\Java\jdk1.6.0_16\bin>

You might also like