Download as pdf or txt
Download as pdf or txt
You are on page 1of 67

Ex.

No :1
Cascading Style Sheets AndEmbedded StyleSheets
Date:

AIM :-

To Create a webpage with Cascadding Style Sheet and Embedded style


Sheets.

ALGORITHM :-

Step 1: Create the linked style sheet using #id1.

Step 2: Create a style sheet using text and css concept.

Step 3: Given the inline style sheet using p.class1 withBackground color black bottom
size=12em.

Step 4: Add a new style sheet for embedded.

Step 5: Stop the program.


Cascading Style Sheets And Embedded StyleSheets
Style.css:-
{
#id1
{
font_size:20;color:green;
}
Program1.html:-
<html>
<style> h1
{
font_size:22; font_weight:bold;color:black;
}
h2{
font_size:18; font_family:Arial Black;color:black;
{
</style>
<link rel=stylesheet href="Style.css">
<body style="background:orange; color:blue; font_size:30">
<h1>cascadding style sheets</h1>
<p><h2>TYPES OF STYLE SHEET</h2></p>
<h2 id="id1">Embedded Style Sheets</h2>
<p class="class1">In this approach,style are designed seperately andembedded in the html
document using style tag</p>
<h2 id="id1">Inlined style sheet</h2>
<p class="class1">style is designed with in the tag or in a line whenneeded</p>
<h2 id="id1">Linked style sheet</h2>
<p class="class1">only styles are written in a seperate file(.css)and it can beused by; any
no.of html documents using link tag</p>
</body>
</html>
OUTPUT:-

RESULT:-

Thus the Web page was created with Cascading Style Sheetand Embedded
Style Sheet.
Ex.No :2

Date: Web Page Creation

AIM:-

To Create a webpage using HTML tag.

ALGORITHM:-

Step 1: Create the web page on the department of computerscience.

Step 2: Using the list type of unordered list.

Step 3: Linking the different pages using linking tag.

1.About Departmnt2.Faculty

3.Course Offered 4.Syllabus 5.Student Strength

Step 4: Stop the program.


Web Page Creation

HOME PAGE:-

<html>
<head>
<h3>
<center>Department of Computer Science</ center></h3></head>
<ul type="disc">
<li><a href="Dept.html">About Department</a></li>
<li><a href="Faculty.html">Faculty</a></li>
<li><a href="Courses.html">Courses Offfered</a></li>
<li><a href="Syllabus.html">Syllabus</a></li>
<li><a href="Studstrength.html">Student Sudstrength</a></li></ul>
</html>

DEPARTMENT :-

<html>
<head><center><h4>ABOUT DEPORTMENT</center></h4></head>
<a href="Homepage.html">Home page</a>
<p>This Department was start in 1993-94</p>
</head>
</html>

FACULTY :-

<html>
<head><center><h4>Faculty</center></h4></head>
<a href="Homepage.html">HomePage</a>
<table border=3 align=center>
<tr><th>S.no</th><th>Name</th><th>Qualification</th><th>Design</th>
</tr>
<tr>
<td>1</td><td>S.Thirumal</td><td>MCA.,M.Phil</td><td>Head ofDepartment</td>
</tr>
<tr>
<td>2</td><td>K.Vijayalakshmi</td><td>Msc.,M.Phil</td><td>Assistant Professor</td>
</tr>
<tr>
<td>3</td><td>V.Meenakshi</td><td>MCA.,M.Phil</td><td>Assistant Professor</td>
</tr>
<tr>
<td>4</td><td>T.G.Babu</td><td>MCA.,M.Phil</td><td>Assistant Professor</td>
</tr>
<tr>

COURSES OFFERED:-

<html>
<head><h4><center>Courses Offered</h4></head>
<a href="Homepage.html">Home Page</a>
<h5>UG Courses</h5>
<table border=3 align=center>
<tr>
<th>S.No</th><th>Course Name</th><th>Duration</th><th>Total no of
student</th><th>Shift</th>
</tr>
<tr>
<td>1</td><td>B.sc(cs)</td><td>3years</td><td>40</td><td>1</td>
</tr>
<tr>
<td>2</td><td>BCA</td></td><td>3years</td><td>40</td><td>1</td>
</tr>
<tr>
<td>3</td><td>Bsc(cs)</td><td>3years</td><td>40</td><td>2</td>
</tr>
<tr>
<td>4</td><td>BCA</td><td>3years</td><td>40</td><td>2</td>
</tr>
</table>
<h5>PG COURSES</h5>
<table border=3 align=center>
<tr>
<th>S.No</th><th>Course Name</th><th>Duration</th><th>Total no of
student</th><th>shift</th>
</tr>
<tr>
<td>1</td><td>Msc(CS)</td><td>2years</td><td>26</td><td>1</td>
</tr>
<tr>
<td>2</td><td>Msc(IT)</td><td>2years</td><td>26</td><td>1</td>
</tr
</table>
</html>

SYALLABUS :-

<html>
<head><h4><center>SYALLABUS</center></h4></head>
<a href="Homepage.html">Home Page</a>
<table border=2>
<tr>
<th>Year/Semester</th>
<th>Subject</th>
<th>Paper</th>
<th>Title of the paper</th>
</tr>
<tr>
<td rowspan=7> 1 Year /1 Semester</td>
<td>Main</td>
<td>Paper 1</td>
<td>Principles Of Communication System</td>
</tr>
<tr>
<td>Main</td>
<td>Paper 2</td>
<td>Object Oriented Programming</td>
</tr>
<tr>
<td>Main</td>
<td>Paper 3</td>
<td>Database Management System</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 1</td>
<td>Object Oriented Programming Lab</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 2</td>
<td>Database Management System Lab</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 3</td>
<td>Visual Programming Lab</td>
</tr>
<tr>
<td>Elective</td>
<td>Paper 1</td>
<td>(To Choose 1 out of 3)<br> A)Computer Architecture<br>
B)Discrete Mathematics<br> C)Operating System</td>
</tr>
<tr>
<td rowspan=7> 1 Year /2 Semester</td>
<td>Main</td>
<td>Paper 4</td>
<td>Visual Programming</td>
</tr>
<tr>
<td>Main</td>
<td>Paper 5</td>
<td>Computer Network</td>
</tr>
<tr>
<td rowspan=1>Compulsory Paper</td>
<td>Human Right</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 1</td>
<td>Object Oriented Programming Lab</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 2</td>
<td>Database Management System Lab</td>
</tr>
<tr>
<td>Main</td>
<td>Practical 3</td>
<td>Visual Programming Lab</td>
</tr>
<tr>
<td>Elective</td>
<td>Paper 1</td>
<td>(To Choose 1 out of 3)<br> A)E_Commerce<br> B)Software Engineering<br>
C)Network</td>
</tr>
</html>

STUDENT STRENGTH:-

<html>
<head>
<h4><center>Student Strength</h4>
<a href="Homepage.html">Home Page</a>
<h5>UG Student Strength</h5>
<table border=2 align=center>
<tr>
<th>Shift 1</th>
<th>Boys</th>
<th>Girls</th>
<th>Total</th>
</tr>
<th>B.Sc Student</th>
<tr>
<td>1 year</td><td>13</td><td>18</td>
</tr>
<tr>
<td>2 year</td><td>14</td><td>17</td>
</tr>
<tr>
<td>3 year</td><td>19</td><td>20</td>
</tr>
<tr>
<td colspan=2></td><td>Total</td><td>101</td>
</tr>
<tr>
<th>BCA Student</th>
</tr>
<tr>
<td>1 year</td><td>13</td><td>18</td>
</tr>
<tr>
<td>2 year</td><td>14</td><td>17</td>
</tr>
<tr>
<td>3 year</td><td>15</td><td>19</td>
</tr>
<tr>
<td colspan=2></td>
<td>Total</td>
<td>62</td>
</tr>
<tr>
<th>Shift 2</th>
<th>Boys</th>
<th>Girls</th>
<th>Total</th>
</tr>
<tr>
<th>B.Sc Student</th>
</tr>
<tr>
<td>1 year</td>
<td>14</td>
<td>18</td>
</tr>
<tr>
<td>2 year</td>
<td>15</td>
<td>17</td>
</tr>
<tr>
<td>3 year</td>
<td>19</td>
<td>20</td>
</tr>
<td colspan=2</td>
<td>Total</td>
<td>103</td>
</tr>
<th>BCA Student</th>
<tr>
<td>1 year</td>
<td>14</td>
<td>18</td>
</tr>
<tr>
<td>2 year</td>
<td>15</td>
<td>17</td>
</tr>
<tr>
<td colspan=2></td>
<td>Total</td>
<td>63</td>
</tr>
</table>
<h5>PG Student Strength</h5>
<table border=2 align=center>
<tr>
<th>Year</th>
<th>Boys</th>
<th>Girls</th>
<th>Total</th>
</tr>
<tr>
<th>M.Sc(CS)Student</th>
</tr>
<tr>
<td>1 Year</td>
<td>14</td>
<td>13</td>
</tr>
<tr>
<td>2 Year</td>
<td>15</td>
<td>16</td>
</tr>
<tr>
<td colspan=2></td>
<td>Total</td>
<td>58</td>
</tr>
<th>M.Sc(IT)Student</th>
</tr>
<tr>
<td>1 Year</td>
<td>14</td>
<td>17</td>
</tr>
<td>2 Year</td>
<td>9</td>
<td>9</td>
</tr>
<tr>
<td colspan=2></td>
<td>Total</td>
<td>49</td>
</tr>
</table></center>
</html>
OUTPUT:-
RESULT:-

Thus the program was created by the Web Page Creation.


Ex.No :3
HTML Form Elements
Date:

AIM:-

To Create a webpage for ordered form using HTML form elements.

ALGORITHM:-

Step 1: Create our E-Shop using java script.

Step 2: Create Customer details (cname,address,mobile no).Step 3: Create the list

item (item name,prize,select check). Step 4: Select the list of items.

Step 5: Display the amount.

Step 6: Stop the program.


HTML Form Element
<html>
<h1><center>Welcome to our E-Shop</center></h1>
<body bgcolor="white">
<script>
function check_add()
{
var i,n,tot; n=myForm.itemsch.length;tot=0;
for(i=0;i<n;i++)
{
if(myForm.itemsch[i].checked) tot=tot+parseInt(myForm.itemsch[i].value);
}
myForm.t4.value=tot;
}
function clear_text()
{
myForm.t1.value=""; myForm.t2.value=""; myForm.t3.value=""; myForm.t4.value="";
}
</script>
<form name="myForm">
CustomerName:<input type="text" value="" name="t1"><br> Address:&nbsp;<input
type="text" value="" name="t2"><br> Mobile:&nbsp;<input type="text" value=""
name="t3"><br>
<table align="center" border=2 name="t">
<tr>
<th>S.No</th>
<th>Item Name</th>
<th>Price</th>
<th>Select check</th>
</tr>
<tr>
<td>1<br>2<br>4<br>5</td>
<td>Monitor<br>Mouse<br>Keyboard<br>CPU<br>Speakers</td>
<td>2000<br>500<br>1000<br>2000<br>1500</td>
<td>
<input type="checkbox" name="itemsch" value="2000"><br>
<input type="checkbox" name="itemsch" value="500"><br>
<input type="checkbox" name="itemsch" value="1000"><br>
<input type="checkbox" name="itemsch" value="2000"><br>
<input type="checkbox" name="itemsch" value="1500"><br>
</td>
</tr>
</table>
Amount:<input type="text" name="t4" value="">
<input type="button" value="ok" onClick="check_add()">
<input type="button" value="cancel" onClick="clear_text()">
</form>
</body>
</html>
OUTPUT:-

RESULT:-

Thus the webpage was created for Order from using HTML Form Element.
Ex.No :4
Validating ClientSide Data
Date:

AIM:-

To Create a webpage for validate client side by using java script.

ALGORITHM:-

Step 1: Create a login form using java script.

Step 2: Create the user name for Textbox1 and password forPassword1.

Step 3: Create the button for add data and clear data.

Step 4: When we add the data function add() will be called.In the function we are
checking for user name and Password.

Step 5: Stop the program.


Validating ClientSide Data
<html>
<head>
<title>Logging Form</title></head>
<center><i><b><h1>Logging Form</h1></b></i></center>
<body bgcolor="white">
<script> function lo()
{
if (f1.t1.value=="thilaga")
{
if(f1.p1.value=="thilaga") window.open("Resume1.html");else
{
alert("incorrect password"); f1.p1.value="";
}}
else
{
alert("incorrect username"); f1.t1.value="";
f1.p1.value="";
}
}
function cl()
{
f1.t1.value="";
f1.p1.value="";
}
</script>
<form name=f1>
username:<input type="text" value="" name=t1><br> password:<input type="password"
value="" name=p1><br>
<input type="button" value="ok" onclick="lo()">
<input type="button" value="cancel" onClick="cl()">
</form>
</body>
</html>
OUTPUT:-
RESULT:-

Thus the webpage was created to validating the data in clientside by using
JavaScript.
Ex.No :5
Screen Saver Animation
Date:

AIM:-

To Design a web page to perform screen saver animation using Javascript.

ALGORITHM:-

Step 1: Create a webpage for display the Image’s using revealtrans Transition.

Step 2: It gives the fade in,fade out image method for revealtrans .

Step 3: When we call the function hide p1() to hide p3() and show P1() to show p3() based
on the Index value.

Step 4: Set the duration time for image’s using display theContinuously.

Step 5: Stop the program.


Screen Saver Animation
<html>
<head>
<title>Panda Walking Animation</title>
<link rel="stylesheet" href = "Pandapro.css">
</head>

<body>
<a href="#" onclick="play()">

<audio id="audio" src="https://git.io/JUW4q" loop="loop"></audio>

<script>
function play()
{
var audio = document.getElementById("audio");
audio.play();
}
</script>

<div id="panda"></div>
<div id="street"></div>
</a>
</body>
</html>

Pandapro.css

body
{
background: url(https://git.io/JUW4t);
background-size: cover;
overflow: hidden;
}

#panda
{
position:relative;
top:300px;
background: url(https://git.io/JUW4L);
width:250px;
height:330px;
animation:walking_animation 1s steps(12) infinite,move_forward 8s linear infinite;
}

@keyframes walking_animation
{
0%{background-position:0px;}
100%{background-position:3000px;}
}

@keyframes move_forward
{
0%{transform:translateX(-100px);}
100%{transform:translateX(1366px);}

#street
{
position:relative;
top:600px;
border-bottom:5px groove green;
}
OUTPUT: -

RESULT:-

Thus the screen saver animation was created using JavaScrip


Ex.No :6
Data Binding Using DHTML
Date:

AIM:-

To Create a webpage to display the text file contents using Data Binding concept in
DHTML.

ALGORITHM:-

Step1: Create a textfile for colorname and colorcode in hexadecimal value.


Step2: Create a webpage for displaying the colorname and colorcode.
Step3: Create four buttons for first,last,previous and next. If we can pressThese buttons
the textfile and content has to be called.
Step4: If we can press the button “first” the first data has to be displayedUsing the
function recordset.Movefirst().
Step5: If we can press the button “last” the last data has to be displayed Using the
function recordset.Movelast().
Step6: If we can press the button “previous” the previous data has to beDescribed. Using
the function recordset.Moveprevious().
Step7: If we can press the button “next” the next data has to be displayedUsing the
function recordset.Movenext().
Step8: Finally the given color has to be apply for the given text.
Data Binding Using DHTML

<html>
<head>
<title>Dynamic RecordSet Viewing</title>
<object id="Colors" classid="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<Param name="DataURL" value="htmlstandardcolor.txt"/>
<Param name="UseHeader" value="TRUE"/>
<Param name="TextQualifier" value="@"/>
<Param name="FieldDelim" value="|"/>
</object>
<script type="text/javascript"> var recordSet=Colors.recordset; function update()
{
h1Title.style.color=colorRGB.innerText;
}
function move(whereTo)
{
switch(whereTo)
{
case "first": recordSet.MoveFirst(); update();
break;
case "previous": recordSet.MovePrevious();if(recordSet.BOF) recordSet.MoveLast();
update();
break;
case "next": recordSet.MoveNext(); if(recordSet.EOF) recordSet.MoveFirst(); update();
break; case "last":
recordSet.MoveLast();update();
break;
}
}
</script>
<style type="text/css">
input{background-color:khaki;color:green;font-weight:bold}
</style>
</head>
<body style="background-color:white">
<h1 style="color:black" id="h1Title"> This is valar's web page</h1>
<span style="position:absolute;left:200;width:270;border-style:groove;text-align:Center;
background-color:cornsilk;padding:10">
<strong>Color Name:</strong>
<span id="ColorName" style="font-family:monospace"datasrc="#Colors"
datafld="ColorName">ABC
</span><br/>
<strong>Color RGB value:</strong>
<span id="colorRGB" style="font-family:monospace"datasrc="#Colors"
datafld="ColorHexRGBValue">ABC</span><br/>
<input type="button" value="First" onclick="move('first');"/>
<input type="button" value="Previous" onclick="move('previous');"/>
<input type="button" value="Next" onclick="move('next');"/>
<input type="button" value="Last" onclick="move('last');"/>
</span>
</body>
</html>
htmlstandardcolor.txt

@ColorName@|@ColorHexRGBValue@@aqua@|@#00FFF@ @black@|@#000000@
@blue@|@#0000FF@ @fuchsia@|@#FF00FF@ @gray@|@#808080@
@green@|@#008000@ @lime@|@#00ff00@ @maroon@|@#800000@
@navy@|@#000080@ @olive@|@#808000@ @purple@|@#800080@
@red@|@#FF0000@ @silver@|@#C0C0C0@ @teal@|@#008080@
@yellow@|@#FFFF00@
OUTPUT:-
RESULT:-

Thus the textfile content was display using databinding in DHTML.


Ex.No :7
Editor Creation Using Applet
Date:

AIM:-

To Create a editor using Java Applet.

ALGORITHM:-

Step 1: To implement AcionListener interface to sample dialog andInterface dialog class.

Step 2: To create a menubar “File” and menu item such as “New”, “Open”,”Close” and
“Quit”.

Step 3: To create a member “Edit” an menu item such as “Cut”,


“Copy”,“Paste”,”Special”,”Debug”,”Testing”.

Step 4: To add File and Edit menubar is applet window.

Step 5: In actionPerformed() method to compare the command Live argument with


“Menuitem”.

Step 6: Finally to access these menubar.


Editor Creation Using Applet

import java.io.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="menu" width=500 height=500>
</applet>*/
class SampleDialog extends Dialog implements ActionListener
{
SampleDialog(Frame parent,String title)
{
super(parent,title,false);
setLayout(new FlowLayout());
setSize(300,200);
add(new Label("press this button"));
Button b=new button("cancel"); add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
dispose();
{
public void paint(Graphics g)
{
g.drawString("this is in the dialog box",10,70)
}
}
class MenuFrame extends Frame
{
String msg="";
CheckboxMenuItem debug,test;
MenuFrame(String title)
{
super(title);
MenuBar mbar=new MenuBar();
setMenuBar(mBar);
Menu file=newMenu("File");
MenuItem item1,item2,item3,item4; f
ile.add(item1=new MenuItem("New..."));
file.add(item2=new MenuItem("Open.."));
file.add(item3=new MenuItem("Close..."));
file.add(new MenuItem("-"));
file.add(item4=new MenuItem("Quit..."));
mbar.add(file);
Menu edit=new Menu("Edit");
MenuItem item5,item6,item7;
edit.add(item5=new MenuItem("Cut..."));
edit.add(item6=new MenuItem("Copy..."));
edit.add(item7=new MenuItem("Paste..."));
edit.add(new MenuItem("-"));
Menu sub=new Menu("Special",true);
MenuItem item8,item9,item10; sub.add(item8=new MenuItem("First..."));
sub.add(item9=new MenuItem("Second.."));
sub.add(item10=new MenuItem("Third..."));
edit.add(debug);
test=new CheckboxMenuItem("Testing"); edit.add(test);
mbar.add(edit);
MyMenuHandler handler=new MyMenuHandler(this); item1.addActionListener(handler);
item2.addActionListener(handler);
item3.addActionListener(handler);
item4.addActionListener(handler);
item5.addActionListener(handler);
item6.addActionListener(handler);
item7.addActionListener(handler);
item8.addActionListener(handler);
item9.addActionListener(handler);
item10.addActionListener(handler);
debug.addItemListener(handler);
test.addItemListener(handler);
MyWindowAdapter adapter=new MyWindowAdapter(this);
addWindowListener(adapter);
}
public void paint(Graphics g)
{
g.drawString(msg,10,200);
if(debug.getStatic()) g.drawString("Debug is on",10,220);
else
g.drawString("Debug is off",10,220);
if(test.getState()) g.drawString("Testing is on",10,240);
else
g.drawString("Testing is off",10,240);
}
}
class MyWindowAdapter extends WindowAdapter
{
MenuFrame menuFrame;
public MyWindowAdapter(MenuFrame menuFrame)
{
this.menuFrame=menuFrame
}
public void WindowClosing(WindowEvent we)
{
menuFrame.dispose();
}
}
class MyMenuHandler implements ActionListener,ItemListener
{
MenuFrame menuFrame;
public MyWindowAdapter(MenuFrame menuFrame)
{
this .menuFrame=menuFrame
}
public void ActionPerformed(ActionEvent ae)
{
String msg="";
String arg=(String)ae.getActionCommand();
if(arg.equals("New..."))
{
msg+="New...";
SampleDialog d=new SampleDialog(menuFrame,"New Dialog box");
d.setVisible(true);
}
else
if(arg.equals("Open...")) msg+="Open...";
else
if(arg.equals("Close...")) msg+="Close";
else
if(arg.equals("Quit...")) msg+="Quit...";
else
if(arg.equals("Edit...")) msg+="Edit...";
else
if(arg.equals("Cut...")) msg+="Cut...";
else
if(arg.equals("Copy...")) msg+="Copy...";
else
if(arg.equals("Paste...")) msg+="Paste...";
else
if(arg.equals("First...")) msg+="First...";
else
if(arg.equals("Second...")) msg+="Second...";
else
if(arg.equals("Third...")) msg+="Third...";
else
if(arg.equals("Debug...")) msg+="Debug...";
else
if(arg.equals("Testing...")) msg+="Testing...";
menuFrame.msg=msg; menuFrame.repaint();
}
public void itemStateChanged(ItemEvent ie)
{
menuFrame.repaint();
}
}
public class menu extends Applet
{
Frame f;
public void init()
{
f=new MenuFrame("Menu Demo");
int width=Integer.parseInt(getParameter("width"));
int height=Integer.parseInt(getParameter("height"));
setSize(width,height);
f.setSize(width,height);
f.setVisible(true);
}
public void start()
{
f.setVisible(true);
}
public void stop()
{
f.setVisible(false);
}
}
OUTPUT:
RESULT:-

Thus the Editor was created using Java Applet.


Ex.No :8
Library Management Using JDBC
Date:

AIM:-

To design a webpage for library management using Java Applet and JDBC.

ALGORITHM:-

Step 1: Create a database for general library information with the field
Bookno,Bookname,Author,Editon and availability.

Step 2: Insert the required data.

APPLICATION SIDE:-

Step 1: Create a database connection.

Step 2: Get the data from database using the statementexecuteQurey(“select * from lib”)
.

Step 3: Print these data. Step 4: Stop the process.


Library Management Using JDBC

import java.sql.*;
import java.sql.DriverManager.*;
import java.lang.*;
import java.lang.String.*;
import java.applet.*;
class Mydata
{
int bookno;
String bookname, author, edition, availability;
Connection conn;
Statement stmt;
ResultSet res;
Mydata()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:db","scott","tiger");
}
catch(Exception e)
{
System.out.println("Connection error");
}
}
void MyOut()
{
try
{
stmt=conn.createStatement();
res=stmt.executeQuery("select * from lib1");
System.out.println(" ------------------------ ");
System.out.println("\n bookno \tbookname\t author\t edition\t avilability\n");
System.out.println(" ----------------------");
while(res.next())
{
bookno=res.getInt(1);
bookname=res.getString(2);
author=res.getString(3);
edition=res.getString(4);
availability=res.getString(5);
System.out.println(bookno+"\t\t"+bookname+"\t\t"+author+"\t\t"+edition+"\
t\t"+availability);
}
res.close();
stmt.close();
conn.close();
}
catch(SQLException e)
{
System.out.println("Reading error");
}
}
}
class report1
{
public static void main(String args[])
{
Mydata m=new Mydata(); m.MyOut();
}
}
OUTPUT:-

RESULT:-

Thus the webpage for library management was desiged using Java Applet and
JDBC.
Ex.No :9
Implementation of RMI/RPC
Date:

AIM:-

To perform implementation o RMI/RPC.

ALGORITHM:-

Step 1:Write an interface program with method AddServerIntf that finds the sum of 2
values.
Step 2:Write an Implementation program to define the AddServerIntf with a method
AddServerImpl method.
Step 3:Write a server program rmiserver in which the instance of the implementation is
created.
Step 4:Create a register by issuing the ―start rmiregistry command at the command
prompt.
Step 5:Compile using the rmi compiler the implementation program for creation of the
stub and skeleton.
Step 6: Bind the implementation object to the registry and name it.
Step 7: Write a client program in which the inputs of two values are obtained from the
command line and the result is displayed.
Step 8:Stop.
Implementation of RMI/RPC
rmiserver.java:-
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.net.*;
import java.io.*;
public class rmiserver
{
public static void main(String args[])throws Exception
{
try
{
implement i=new implement();
Naming.rebind("server",i);
System.out.println("\nServer is ready");
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
}
interface.java:-
import java.rmi.*;
import java.rmi.server.*;
public interface inter extends Remote
{
public void fact(int n)throws RemoteException;
}
rmiclient.java:-
import java.rmi.*;
import java.rmi.registry.*;
import java.net.*;
import java.io.*;
public class rmiclient
{
public static void main(String args[])throws RemoteException
{
try
{
String host="rmi:/server";
inter a=(inter)Naming.lookup(host);
System.out.println("enter any number:");
DataInputStream dis=new DataInputStream(System.in);
int n=Integer.parseInt(dis.readLine());
a.fact(n);
}
catch(Exception e)
{
System.out.println("exception:"+e);
}
}
}
implement.java:-
import java.rmi.server.*;
import java.rmi.registry.*;
import java.rmi.*;
import java.io.*;
public class implement extends UnicastRemoteObject implements inter
{
public implement() throws RemoteException
{
}
public void fact(int n)throws RemoteException
{
int f=1;
for(int i=1;i<=n;i++) f=f*i;
System.out.println("the factorial of"+n+"is"+f);
}}
OUTPUT:

SERVER:

CLIENT:
RESULT:-
Thus the above program has been executed successfully.
Ex.No :10
ON-QUIZ Using Java Server Page
Date:

AIM:-

To Create a webpage to conduct On-Line Quiz using java server page.

ALGORITHM:-

Step:1 Create the question using HTML.


Step:2 Create a JSP file for checking the answer.
Step:3 We can get the parameter of the specified textboxes and assigned it to variable.

Step:4 We can check the given data is equal to correct answer thenthe mark is to be
assigned otherwise the result is zero.
Step:5 Finally the web page is to be displayed using the above statement.
ON_QUIZ Using Java Server Page

Onlinequiz.html

<html>
<head>
<title>Quiz</title>
</head>
<body bgcolor="white">
<marquee bgcolor="green">
<font color="yellow">
<h2>&nbsp Quiz from Expert Group</h2>
</font>
</marquee>
<br>
<form method="post" action="http://localhost:8085/Onlinequiz.jsp"> 1.find out the
connection?
<input type="radio"name="r1" value="cable">cable
<input type="radio"name="r1" value="protocol">protocol
<input type="radio"name="r1" value="port">port
<br>
2. find out the Output device?
<input type="radio"name="r2" value="pendrive">pendrive
<input type="radio"name="r2" value="speaker">speaker
<input type="radio"name="r2" value="keyboard">keyboard
<br>
3. find out the Input device?
<input type="radio"name="r3" value="projector">projector
<input type="radio"name="r3" value="mouse">mouse
<input type="radio"name="r3" value="printer">printer
<br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
Onlinequiz.jsp

<%@ page import="java.lang.*"%>


<%@ page import="javax.servlet.jsp.*"%>
<html>
<body>
<center><font color="blue">Successfully completed</font></center>
<%
String str1=request.getParameter("r1"); String str2=request.getParameter("r2"); String
str3=request.getParameter("r3"); int correct=0;
int wrong=0; if(str1.equals("cable"))
++correct;else
++wrong; if(str2.equals("speaker"))
++correct;else
++wrong; if(str3.equals("mouse"))
++correct;else
++wrong;
Integer in1=new Integer(correct); Integer in2=new Integer(wrong);
%>
<h3><center><font face="verdana"> result</font></center><font color="green"><br>
<%out.print("correct answer"+in1.toString());%>
<font color="red"><br>
<%out.print("wrong answer"+in2.toString());%>
</body>
</html>
OUTPUT:
RESULT:-

Thus the above program has been executed successfully.


Ex.No :11
Request Page Header Details
Date:

AIM:-

To Display the header details during request of a page.

ALGORITHM:-

Step 1: Start the program.

Step 2: Create a class with header information extends http servlet.

Step 3: Give the request and response to the servlet session.

Step 4: Initialize the header value in null.

Step 5: Run the program for Appache Tomcat7.0. Step 6: Stop the program.
Request Page Header Details
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class req extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws
IOException,ServletException
{
printHeader(req,res);
}
public void doPost(HttpServletRequest req,HttpServletResponse res)throws
IOException,ServletException
{
printHeader(req,res);
}
public void printHeader(HttpServletRequest req,HttpServletResponse res)throws
IOException,ServletException
{
String header=null;
String head="<html><head><title>Header Information</title></head><body>";
String foot="</body></html>";
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
Enumeration enumeration=req.getHeaderNames();
pw.println(head);
pw.println("<h2>Header Information</h2>/");
//pw.println("<B>RequestMethod:</B>"
//+req.getMethod()++"<BR>\n"+"<B>Request
Protocol:</B>"+req.getProtocol()+"<BR><BR>\n");pw.println("<table>");
while(enumeration.hasMoreElements())
{
header=(String)enumeration.nextElement();
if(header!=null)
{
pw.println("<tr><td><b>"+header+"</td>");
pw.println("<td>"+req.getHeader(header)+"</td></tr>");
}
}
pw.println("</table><br>");pw.println(foot);
}
}
OUTPUT:

RESULT:-

Thus the above program was successfully executed.


Ex.No :12
SESSION DEMONSTRATE
Date:

AIM:-

To Display the Session demonstrate during request of a page.

ALGORITHM:-

Step 1: Start the program.

Step 2: Create a class with Session Demonstrate extends http servlet.

Step 3: Give the request and response to the servlet session.

Step 4: Initialize the xml servlet.

Step 5: Run the program

Step 6: Stop the program.


SESSION DEMONSTRATE
import java.io.*;
import javax.servlet.*;
import javax.servelt.http.*;
import java.util.*;
//Extend HttpServlet class
public class sessionDemo extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
ServletException,IOException
{
//create a session object if it is already not created
HttpSession session=request.getSession(true);
//Get session creation time
Data createTime=new Data(session.getCreationTime());
//Get last access time of this web page
Date lastAccessTime=newDate(session.getLastAccessedTime());
String title="Welcome Back to my website";
Integer visitCount=newInteger(0);
String visitCountKey=newString("visitCount");
String UserID key=newString("USerID");
String UserID=new String("surrendra");
//check if this is new comer on your web page
if(session.isNew())
{
tittle="Welcome to my website";
Session.SetAttribute(UserID key,UserID)
}
else
{
VisitCount=(Integer)session.getAttribute(visitCountKey);
VisitCount=visitCount+1;
UserID=(string)session.getAttribute(UserID key);
}
session.setAttribute(visitCountKey,visitCount);
//set response content type
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String docType="<!doctype html public\"_//W3C//dtd html4.0"+"transitional//on\">\n";
out.println(docType+
"<html>\n"+
"<head><title>"+title+"</title></head>\n"+
"<body bgcolor=\"#e5f7c0\">\n"+
"<h1 align=\"center\">sessionInformation</h2>\n"+
"<table border=\"1\"align=\"senter\">\n"+
"<tr bgcolor=\"#eadf8c\">\n"+
"<th>Session info</th><th>value</th></tr>\n"+
"<tr>\n"+
"<td>id</td>\n"+
"<td>"+session.getId()+"<\td><\tr>\n"+
"<tr>\n"+
"<td>Time of last Access</td>\n"+
"<td>"+LastAccessTime+
"</td></tr>\n"+
"<tr>\n"+
"<td>UserID</td>\n"+
"<td>"+UserID+
"</td></tr>\n"+"<tr>\n"+
"<td>Number of visits</td>\n"+
"<td>"+visitCount+"</td></tr>\n"+
"</table>\n"+“</body></html>”);
}}
OUTPUT:
Welcome to my website
Session information
Session info Value
Id 10294278B7292F4AA21541
FF4EB654FC
Creation time Tue Dec 1311:00:43ISI 2016
Time at last access Tue Dec 1311:00:43ISI 2016
User ID Surendar
Number of visits 0

Welcome Back to my website


Session information
Session info Value
Id 10294278B7292F4AA21541
FF4EB654FC
Creation time Tue Dec 1311:00:43ISI 2016
Time at last access Tue Dec 1311:00:43ISI 2016
User ID Surendar
Number of visits 12

RESULT:-

Thus the above program was successfully executed.

You might also like