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

IP Lab Coding329

The document discusses creating a web page using HTML and dividing it into frames. It includes the code for the main page and individual frames to display information about a college, with navigation links between the frames. Images are also mapped to different regions to link to additional pages for each area.

Uploaded by

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

IP Lab Coding329

The document discusses creating a web page using HTML and dividing it into frames. It includes the code for the main page and individual frames to display information about a college, with navigation links between the frames. Images are also mapped to different regions to link to additional pages for each area.

Uploaded by

3Dotzz RnD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 72

CS2358 INTERNET PROGRAMMING LAB Reg.

No:20609104329

1. CREATE A WEB PAGE AND DIVIDE IT BY FRAMES WITH


HYPERLINK USING HTML

PROGRAM:

home.html
<html>
<head>
<title>WEB PAGE</title>
</head>
<frameset rows="18%,*,5%" bordercolor="RED">
<frame src="frame1.html"/>
<frameset cols="20%,*">
<frame src="frame2.html" name="f2"/>
<frame src="intro.html" name="f3"/>
</frameset>
<frame src="copyright.html"/>
</frameset>
<body>
</body>
</html>

frame1.html
<html>
<head>
<title>Frame1</title>
</head>
<body bgcolor="INDIYA">
<center>
<font color="black" size="5" face="Monotype Corsiva">
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<b>MAAMALLAN INSTITUTE OF TECHNOLOGY</b><br />


Maamallan Nagar,Vada Mangalam, <br />
Sriperumpudhur.
</font>
</center>
<marquee>
<font color="red" face="Monotype Corsiva">
<i>You can see some information in this page by clicking relevant buttons</i>
</font>
</marquee>
</body>
</html>

frame2.html
<html>
<body bgcolor=”indiga”>
<br><br>
<center>
<b><i>Click Here</i></b><br><br>
<a href="intro.html" target="f3"><h3><font color=black>Introduction</font></h3></a>
<a href="Contact.html" target="f3"><h3><font color=black>ContactUs</font></h3></a>
<a href="feedback.html" target="f3"><h3><font color=black>FeedBack</font></h3></a>
<a href="album.html" target="f3"><h3><font color=black>Album</font></h3></a>
</center>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

copyright.html
<html>
<head>
<title>Album</title>
</head>
<body>
<p align="right">CopyRights@Maamallan Institute Of Technology</p>
</body>
</html>

intro.html
<html>
<head>
<title>Introduction</title>
</head>
<body bgcolor="facbdefgh">
<br> <br><br>
<font color="black" face="Courier New">Maamallan Institute of Technology was formed by
our belowed chairmen Dr.Jeppiaar M.A,B.L,Phd., </font>
</body>
</html>

feedback.html
<html>
<head>
<title>feedback</title>
</head>
<body>
<center>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<table bgcolor="aqua" width="100%" height="100%">


<tr>
<td width="25%">Name </td>
<td width="75%"> <input type="text" name="txtname" /></td>
</tr>
<tr>
<td>Phone </td>
<td><input type="text" name="txtphone" /></td>
</tr>
<tr>
<td>Address </td>
<td><input type="text" name="txtAddress" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="txtemail" /></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" name="txtcity" /></td>
</tr>
<tr>
<td>Country</td>
<td><select name="cmbcountry">
<option>India</option>
<option>US</option>
<option>Sri Lanka</option>
<option>USA</option>
<option>Australia</option>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<option>Canada</option>
<option>Pakistan</option>
<option>Bangaladesh</option>
</select>
</td>
</tr>
<tr>
<td>Hobbies</td>
<td>
<input type="checkbox" name="chkplaying" />playing
<input type="checkbox" name="chkreading" />Reading
<input type="checkbox" name="chkpainting"/>Painting
</td>
</tr>
<tr>
<td>Feed back</td>
<td><textarea name="ta"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="btnSave" value="Save" />
</td>
</tr>
</table>
</center>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

album.html
<html>
<head>
<title>Album</title>
</head>
<body>
<font size="12">My Favorite Picture<font>
<img src="water.jpg" width="200" height="150"/>
</body>
</html>

contact.html
<html>
<head>
<title>Biodata</title>
</head>
<body>
<center>
<table border="1">
<tr>
<td width="25%"> Name </td>
<td width="75%"> MAAMALLAN INSTITUTE OF TECHNOLOGY</td>
</tr>
<tr>
<td>Address </td>
<td>Maamallan Nagar,Vada Mangalam,<br />Sriperumpudhur. </td>
</tr>
<tr>
<td>Website</td>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<td>www.jeppiaarmaamallan.com</td>
</tr>
<tr>
<td>Eemail</td>
<td>[email protected]</td>
</tr>
</table>
</center>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

2.IMAGE MAPPING

PROGRAM:

World.html
<html>
<head>
<title> World Information </title>
</head>
<body>
<map name="world">
<img height=300 width=800 src = "..\..\images\pastel.gif" ismap usemap=#world>
<area name="asia" shape="rect" coords="520,20,730,185" href="asia.html">
<area name="measia" shape="circle" coords="480,125,30" href="measia.html">
<area name="samerica" shape = "circle" coords="235,200,55" href="samerica.html">
<area name="africa" shape="circle" coords="420,180,55" href="africa.html">
<area name="namerica" shape = "rect" coords="55,15,325,180" href="namerica.html">
<area name="europe" shape = "rect" coords="335,40,495,85" href="europe.html">
<area name="australia" shape="rect" coords="615,185,750,275" href="oceania.html">
</map>
<h3> General information about our world <h3>
<small><i>
<ul>
<li> Most populated country : China Population 1,307,000,000</li>
<li>world's tallest mountain, Mt Everest in Nepal 29,025 ft. (8.850 m)</li>
<li>world's lowest point, found in the Dead Sea, Israel/Jordan, at 1,286 ft (392m)
below sea level</li>
<li>world's deepest lake Lake Baykal, Siberia, Russia, 5369 ft (1637 m)</li>
<li>worlds longest river nile river 4,160 miles (6,693 km) in length</li>
<li>worlds largest desert sahara desert approximately 3,500,000 sq. miles (9,065,000
sq. km)</li>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<li>World's longest coast line: coast line in Canada longest at 243792 km (151485
miles)</li>
<li>Worlds's largest city: Tokyo, Japan (35327000 )</li>
</ul>
</i></small>
</body>
</html>

Africa.html
<html>
<head>
<title>AFRICA</title>
</head>
<body>
<h3 align=center>Africa includes 53 individual countries</h3>
<img align="left" src="..\..\images\africa.gif" height=320 width=320></img><br>
<table border=0>
<tr>
<th align=left>Continent Size:</th>
<td align=left>30,065,000 sq km (11,608,000 sqm)</td>
</tr>
<tr>
<th align=left>Percent of Earth's Land:</th>
<td align=left>20.2%</td>
</tr>
<tr>
<th align=left>Total Population:</th>
<td>877,500,000</td>
</tr>
<tr>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<th align=left>Most populated countries:</th>


</tr>
<tr>
<td></td>
<td>
<table>
<tr>
<th><small>Country</small></th>
<th><small>Population</small></th>
</tr>
<tr>
<td><small><i>Nigeria</i></small></td>
<td align=right>
<small><i>125,750,356</i></small>
</td>
</tr>
<tr>
<td><small><i>Egypt</i></small></td>
<td align=right>
<small><i>76,117,421</i></small>
</td>
</tr>
<tr>
<td><small><i>Ethiopia</i></small></td>
<td align=right>
<small><i>71,336,571</i></small>
</td>
</tr>
<tr>
<td><small><i>Congo</i></small></td>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<td align=right>
<small><i>58,317,930</i></small>
</td>
</tr>
<tr>
<td><small><i>South Africa</i></small></td>
<td align=right>
<small><i>44,448,470</i></small>
</td>
</tr>
<tr>
<td><small><i>Sudan</i></small></td>
<td align=right>
<small><i>39,148,162</i></small>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

3. PROGRAM TO CREATE A WEBPAGE USING HTML WITH


STYLE SHEET(CSS)

1) INTERNAL CSS PROGRAM:

PROGRAM:
<html>
<head>
<title>INTERNAL CSS</title>
<style type="text/css">
body
{
COLOR:red;
FONT-FAMILY: 'Arial';
BACKGROUND: yellow;
}
p
{
MARGIN-LEFT:25 px;
COLOR:BLUE;
}
ul
{
MARGIN-LEFT:35px;
COLOR:'green';
FONT-FAMILY: 'VERDANA';
}
</style>
</head>
<body>
<p align=center>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<strong><u> PG COURSES</u></strong>
</p>
<ul>
<li>MCA</li>
<li>MBA</li>
</ul>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

2) EXTERNAL CSS PROGRAM:


PROGRAM:
<html>
<head>
<link REL="STYLESHEET" TYPE="TEXT/CSS" HREF="yellow.css">
<title>External CSS Program</title>
</head>
<body>
<p align=center><strong><Font size=5>MIT</Font></strong></p>
<p align=left><strong><u>COURSE OFFERED</u></strong></p>
<font face="Arial">
<ul>
<li><a href="int1.html">PG COURSE</a></li>
<li><a href="int2.html">UG COURSE</a></li>
</ul>
</font>
</body>
</html>

yellow.css
body
{
background:YELLOW;
FONT-FAMILY:'Elephant';
}
p
{
MARGIN-LEFT:25px;
COLOR:green;
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

Int1.html
<html>
<head>
<title>this is PG course</title>
</head>
<body>
<li>MCA</li>
<li>MBA</li>
</body>
</html>

Int2.html:
<html>
<head>
<title>this is UG course</title>
</head>
<body>
<li>CSE</li>
<li>IT</li>
<li>ECE</li>
<li>MECH</li>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

3) INLINE CSS PROGRAM:


PROGRAM:
<html>
<head>
<title>INLINE STYLE</title>
</head>
<body BGCOLOR=pink>
<p style="FONT-FAMILY:'Time New Roman';color:black;font-style:bold">
<u>UG COURSE</u>
</p>
<ul style="font-family:'Elephant';color:red;font-style:italic">
<li>CSE</li>
<li>IT</li>
<li>ECE</li>
<li>MECH</li>
</ul>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

4. FORM VALIDATION USING JAVASCRIPT

PROGRAM:
<html>
<head>
<title>Validating Form Controls</title>
<style type="text/css">
table
{
border:1px solid black;
width:70%;
height:50%;
}
</style>
<script type="text/javascript" language="javascript">
function DoValidation()
{
if(frm.txtName.value=="")
{
alert("Please Enter the User Name");
frm.txtName.focus();
return false;
}
if(frm.txtPwd.value=="")
{
alert("Please Enter the Password");
frm.txtPwd.focus();
return false;
}
else if(frm.txtConPwd.value=="")
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

{
alert("Please Enter the Confirm Password");
frm.txtConPwd.focus();
return false;
}
if(frm.txtPwd.value.length<6 || frm.txtConPwd.value.length<6)
{
alert("Password Should have atleast 6 characters");
return false;
}
if(frm.txtPwd.value !=frm.txtConPwd.value)
{
alert("Confirm Pwd Should same as ur password");
frm.txtConPwd.focus();
return false;
}
if(frm.txtEmail.value =="")
{
alert("Please Enter the Email.");
frm.txtEmail.focus();
return false;
}
else if(frm.txtEmail.value !="")
{
if(frm.txtEmail.value.indexOf('@')<=0)
{
alert("Your email format is incorrect");
frm.txtEmail.focus();
return false;
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

}
else if(frm.txtEmail.value.indexOf('.')<=0)
{
alert("Your email format is incorrect");
frm.txtEmail.focus();
return false;
}
}
if(frm.txtPh.value=="")
{
alert("Please Enter the Phone No");
frm.txtPh.focus();
return false;
}
else if(frm.txtPh.value!="")
{
if(isNaN(frm.txtPh.value))
{
alert("Please Enter the Phone No Correctly");
frm.txtPh.focus();
return false;
}
else if(frm.txtPh.value.length!=10)
{
alert("Please Enter the Phone No Correctly 10 digits");
frm.txtPh.focus();
return false;
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

if(frm.txtAddress.value=="")
{
alert("Please Enter the Address");
frm.txtAddress.focus();
return false;
}
if(frm.cmbNationality.selectedIndex==0)
{
alert("Please Select the Nationality");
frm.cmbNationality.focus();
return false;
}
if(frm.filePhoto.value=="")
{
alert("Please Browse and Upload your Photo");
frm.filePhoto.focus();
return false;
}
if(frm.cbxAccept.checked==false)
{
alert("Please Accept the terms and condition");
frm.cbxAccept.focus();
return false;
}
else
{
alert("Your REcords saved Corrctly");
return false;
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

}
function sel()
{
alert(frm.cmbNationality.options[frm.cmbNationality.selectedIndex].value);
}
</script>
</head>
<body>
<form name="frm">
<table align="center">
<tr>
<td>User Name :</td>
<td><input type="text" name="txtName" /></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="txtPwd" /></td>
</tr>
<tr>
<td>Confirm Password :</td>
<td><input type="password" name="txtConPwd" /></td>
</tr>
<tr>
<td>E mail:</td>
<td><input type="text" name="txtEmail" /></td>
</tr>
<tr>
<td>Phone :</td>
<td><input type="text" name="txtPh" /></td>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

</tr>
<tr>
<td>Address :</td>
<td><textarea name="txtAddress" cols="15" rows="4"></textarea></td>
</tr>
<tr>
<td>Nationality :</td>
<td><select name="cmbNationality" onchange="sel();">
<option value="Select">Select</option>
<option value="India">India</option>
<option value="US">US</option>
<option value="SL">Sri Lanka</option>
<option value="China">China</option>
<option value="Eng">England</option>
</select>
</td>
</tr>
<tr>
<td>Gender :</td>
<td>
<input type="radio" checked="checked" value="Male" name="rdGender" />Male
<input type="radio" value="FeMale" name="rdGender" />FeMale
</td>
</tr>
<tr>
<td>Photo :</td>
<td><input type="file" name="filePhoto" /></td>
</tr>
<tr>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<td colspan="2"><input type="checkbox" name="cbxAccept" />


Accept all the conditions
</td>
</tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="Save" name="btnSubmit" onclick="DoValidation();" />
<input type="reset" value="Reset" name="btnReset" />
</td>
</tr>
</table>
</form>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

5.a) TEXT FIELD

PROGRAM:
/* <applet code=TextApplet height=300 width=400> </applet>*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class TextApplet extends Applet implements ActionListener


{
String msg=" ";
TextField ip1=new TextField(5);
TextField ip2=new TextField(6);
Button b1=new Button("Add");
public void init()
{
this.add(ip1);
this.add(ip2);
this.add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
int sum=0;
String t1=ip1.getText();
String t2=ip2.getText();
int a=Integer.parseInt(t1);
int b=Integer.parseInt(t2);
sum=a+b;
msg="Sum is"+sum;
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,6,100);
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

5. b) PROGRAM TO CREATE COLOR PALETTE

PROGRAM:
/* <applet code=palette height=600 width=600>
</applet> */
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class palette extends Applet implements ActionListener,ItemListener
{
Button[] colors;
Checkbox foreground,background;
TextArea workarea;
CheckboxGroup cbg;
Panel buttonpanel,checkpanel,palettepanel;
String colour;
public void init()
{
buttonpanel=new Panel();
buttonpanel.setLayout(new GridLayout(3,3));
colors=new Button[9];
colors[0]=new Button("RED");
colors[1]=new Button("GREEN");
colors[2]=new Button("BLUE");
colors[3]=new Button("CYAN");
colors[4]=new Button("ORANGE");
colors[5]=new Button("WHITE");
colors[6]=new Button("BLACK");
colors[7]=new Button("YELLOW");
colors[8]=new Button("PINK");
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

for(int i=0;i<9;i++)
{
colors[i].addActionListener(this);
buttonpanel.add(colors[i]);
}
checkpanel=new Panel();
checkpanel.setLayout(new FlowLayout());
cbg=new CheckboxGroup();
foreground=new Checkbox("ForeGround",cbg,true);
background=new Checkbox("BackGround",cbg,false);
foreground.addItemListener(this);
background.addItemListener(this);
checkpanel.add(foreground);
checkpanel.add(background);
workarea=new TextArea(8,40);
workarea.setFont(new Font("Garamond",Font.BOLD,20));
palettepanel=new Panel();
palettepanel.setLayout(new BorderLayout());
palettepanel.add(workarea,BorderLayout.CENTER);
palettepanel.add(checkpanel,BorderLayout.EAST);
palettepanel.add(buttonpanel,BorderLayout.SOUTH);
add(palettepanel);
}
public void itemStateChanged(ItemEvent ie)
{
}
public void actionPerformed(ActionEvent ae)
{
colour=ae.getActionCommand();
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

if(foreground.getState()==true)
workarea.setForeground(getColour());
if(background.getState()==true)
workarea.setBackground(getColour());
}
public Color getColour()
{
Color mycolor=null;
if(colour.equals("RED"))
mycolor=Color.red;
if(colour.equals("GREEN"))
mycolor=Color.green;
if(colour.equals("BLUE"))
mycolor=Color.blue;
if(colour.equals("CYAN"))
mycolor=Color.cyan;
if(colour.equals("ORANGE"))
mycolor=Color.orange;
if(colour.equals("WHITE"))
mycolor=Color.white;
if(colour.equals("BLACK"))
mycolor=Color.black;
if(colour.equals("YELLOW"))
mycolor=Color.yellow;
if(colour.equals("PINK"))
mycolor=Color.pink;
return mycolor;
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

6.PROGRAMS TO INVOKE SERVLETS FROM HTML FORMS USING


SERVLETS

PROGRAM:
Html

<html>
<head>
<title> Invoking Servlet From Html </title>
</head>
<body>
<form action = "http://localhost:8080/servlet/SampleServlet" method="GET">
<p>Press the button to invoke servlet<p>
<input type="submit" value="Go for it!">
</form>
</body>
</html>

Servlet
SampleServle.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SampleServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException
{
PrintWriter out;
try
{
out= res.getWriter();
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

out.print("<html>
<head>
<title> Response From Servlet<title>
</head>
<body>
<h3>This Text Is Generated By Invoked Servlet </h3>
</body>
</html>");
}
catch(IOException ie)
{
ie.printStackTrace();
}
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

7 a) ONLINE EXAMINATION
PROGRAM:
Exam.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page language ="java" import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%
String SeatNum,Name;
String ans1,ans2,ans3,ans4,ans5;
int a1,a2,a3,a4,a5;
a1=a2=a3=a4=a5=0;
Connection connect=null;
Statement stmt=null;
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:MyDsn";
connect=DriverManager.getConnection(url);
if(request.getParameter("action")!=null)
{
SeatNum=request.getParameter("Seat_no");
Name=request.getParameter("Name");
ans1=request.getParameter("group1");
if(ans1.equals("True"))
a1=a2;
else
a1=0;
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

ans2=request.getParameter("group2");
if(ans2.equals("True"))
a2=0;
else
a2=2;
ans3=request.getParameter("group3");
if(ans3.equals("True"))
a3=0;
else
a3=2;
ans4=request.getParameter("group4");
if(ans4.equals("True"))
a4=2;
else
a4=0;
ans5=request.getParameter("group5");
if(ans5.equals("True"))
a5=0;
else
a5=2;
int Total=a1+a2+a3+a4+a5;
stmt=connect.createStatement();
String query= "INSERT INTO Exam(SeatNum,Name,Total) VALUES
("+SeatNum+",'"+Name+"',"+Total+")";
int result=stmt.executeUpdate(query);
stmt.close();
stmt=connect.createStatement();
query="SELECT * FROM Exam WHERE Name='"+Name+"'";
rs=stmt.executeQuery(query);
%>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<html>
<head>
<title>Student Mark List</title>
</head>
<body bgcolor=khaki>
<center>
<h2>Student MarkSheet</h2>
<h3>Name of the College:ABC College of Engineering</h3>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td><b>Seat_No</b></td>
<td><b>Name</b></td>
<td><b>Marks</b></td>
</tr>
<%
while(rs.next())
{
%>
<tr>
<td><%=rs.getInt(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getInt(4)%></td>
</tr>
<%
}
rs.close();
stmt.close();
connect.close();
%>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

</table>
</center>
<br/><br/><br/>
<table>
<tr>
<td><b>Date:<%= new java.util.Date().toString()%></b></td>
</tr>
<tr>
<td><b>Signature:X.Y.Z</b></td>
</tr>
</table>
<a href="http://localhost:8080/MyWeb/Exam.jsp">Click here to go back</a>
</body>
</html>
<%
}
Else
{
%>
<html>
<head>
<title>Online Examination</title>
<script language="javascript" type="text/javascript">
function validation(Form_obj)
{
if(Form_obj.Seat_no.value.length==0)
{
alert("Please fill up the seat number");
Form_obj.Seat_no.focus();
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

return false;
}
if(Form_obj.Name.value.length==0)
{
alert("Please fill up the name");
Form_obj.Name.focus();
return false;
}
return true;
}
</script>
</head>
<body bgcolor=lightgreen>
<center><h1>Online Examination</h1></center>
<form action="Exam.jsp" method="post" name="entry" onSubmit="return
validation(this);">
<input type="hidden" value="list" name="action">
<table>
<tr>
<td><h3>Seat Number</h3></td>
<td><input type="tex" name="Seat_no"></td>
</tr>
<tr>
<td><h3> Name</h3></td>
<td><input type="text" name="Name" size=50></td>
</tr>
<hr/>
<tr>
<th>Total Marks :10(Each question carries equal marks)</th>
<td><b>Time:15 min</b></td>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

</tr>
</table>
<hr/>
<b>1.Apache is an open source web server</b><br/>
<input type="radio" name="group1" value="True">True
<input type="radio" name="group1" value="False">False<br>
<b>2.In modern PC there is no cache memory</b><br/>
<input type="radio" name="group2" value="True">True
<input type="radio" name="group2" value="False">False<br>
<b>3.Tim-Berner Lee is the originator of java</b><br/>
<input type="radio" name="group3" value="True">True
<input type="radio" name="group3" value="False">False<br>
<b>4.JPG is not a video file extension</b><br/>
<input type="radio" name="group4" value="True">True
<input type="radio" name="group4" value="False">False<br>
<b>5.HTTP is a stateful protocol</b><br/>
<input type="radio" name="group5" value="True">True
<input type="radio" name="group5" value="False">False<br>
<center>
<input type="submit" value="Submit">
<input type="reset" value="Clear">
</center>
</form>
</body>
</html>
<%
}
%>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

TABLE DESIGN:
Exam(Table in MS Access)
Table Name:Exam
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

7.b) STUDENT MARKLIST

PROGRAM
Register.java

import java.io.*;
import java.awt.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class register extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse resp)
{
try
{
resp.setContentType("text/html");
PrintWriter out=resp.getWriter();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:student");
Statement stmt=con.createStatement();
String regno=req.getParameter("txtreg");
String name=req.getParameter("txtname");
String age=req.getParameter("txtage");
int a=Integer.parseInt(age);
String mark1=req.getParameter("txtMark1");
String mark2=req.getParameter("txtMark2");
String mark3=req.getParameter("txtMark3");
int m1=Integer.parseInt(mark1);
int m2=Integer.parseInt(mark2);
int m3=Integer.parseInt(mark3);
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

int result=stmt.executeUpdate("insert into student (RegNo, Name,


Age, Mark1, Mark2, Mark3) values('"+ regno +"','"+ name +"',"+ a
+","+ m1 +","+ m2+","+m3+")");
ResultSet rs=stmt.executeQuery("select * from student");
out.println("<html> <head> <title>DBCON</title> </head> <body>
<table border=1> <tr bgcolor=cyan> <th>RegNo</th>
<th>Name</th> <th>Age</th> <th>Mark1</th> <th>Mark2</th>
<th>Mark3</th> </tr>");
while(rs.next())
{
out.println("<tr><td>"+rs.getString(2)+"</td>");
out.println("<td>"+rs.getString(3)+"</td>");
out.println("<td>"+rs.getInt(4)+"</td>");
out.println("<td>"+rs.getInt(5)+"</td>");
out.println("<td>"+rs.getInt(6)+"</td>");
out.println("<td>"+rs.getInt(7)+"</td>");
out.println("</tr>");
}
out.println("</table></body></html>");
stmt.close();
con.close();
}
catch(Exception e)
{
out.println("Exception Occured");
}
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

Marklist.html
<html>
<head>
<title>Student Mark List</title>
</head>
<body>
<form method="GET" action="http:\\localhost:8080\examples\servlet\register">
<h1 align="center">Student Mark List</h1>
<table align="center">
<tr>
<td>Enter your Reg no:</td>
<td><input type="text" name="txtreg"/></td>
</tr>
<tr>
<td>Enter your Name:</td>
<td><input type="text" name="txtname"/></td>
</tr>
<tr>
<td>Enter your Age:</td>
<td><input type="text" name="txtage"/></td>
</tr>
<tr>
<td>Enter your Mark1:</td>
<td><input type="text" name="txtMark1"/></td>
</tr>
<tr>
<td>Enter your Mark2:</td>
<td><input type="text" name="txtMark2"/></td>
</tr>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<tr>
<td>Enter your Mark3:</td>
<td><input type="text" name="txtMark3"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input value="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

TABLE DESIGN:
Student(Table in MS Access)
Table Name:Student
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

8.PROGRAM USING XML-SCHEMA-XSLT/XSL


catalog.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>


<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="red">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

catalog.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<title>Still got the blues</title>


<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
<cd>
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
<cd>
<title>One night only</title>
<artist>Bee Gees</artist>
<country>UK</country>
<company>Polydor</company>
<price>10.90</price>
<year>1998</year>
</cd>
<cd>
<title>Sylvias Mother</title>
<artist>Dr.Hook</artist>
<country>UK</country>
<company>CBS</company>
<price>8.10</price>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<year>1973</year>
</cd>
<cd>
<title>Maggie May</title>
<artist>Rod Stewart</artist>
<country>UK</country>
<company>Pickwick</company>
<price>8.50</price>
<year>1990</year>
</cd>
<cd>
<title>Romanza</title>
<artist>Andrea Bocelli</artist>
<country>EU</country>
<company>Polydor</company>
<price>10.80</price>
<year>1996</year>
</cd>
<cd>
<title>When a man loves a woman</title>
<artist>Percy Sledge</artist>
<country>USA</country>
<company>Atlantic</company>
<price>8.70</price>
<year>1987</year>
</cd>
<cd>
<title>Black angel</title>
<artist>Savage Rose</artist>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<country>EU</country>
<company>Mega</company>
<price>10.90</price>
<year>1995</year>
</cd>
<cd>
<title>1999 Grammy Nominees</title>
<artist>Many</artist>
<country>USA</country>
<company>Grammy</company>
<price>10.20</price>
<year>1999</year>
</cd>
<cd>
<title>For the good times</title>
<artist>Kenny Rogers</artist>
<country>UK</country>
<company>Mucik Master</company>
<price>8.70</price>
<year>1995</year>
</cd>
</catalog>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

9. PROGRAM USING AJAX


Ajax.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0/Transitional//EN">


<html>
<head>
<script type="text/javascript">
function LoadAjax()
{
var xmlhttp;
if(window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.xmlhttp");
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mydiv").innerHTML =
xmlhttp.responseText;
}
}
xmlhttp.open("GET",
"http://localhost:8080/examples/servlet/SampleServlet ",true);
xmlhttp.send();
}
</script>
<title>AJAX PROGRAM</title>
</head>
<body>
<div id="mydiv"></div>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

<input type="button" value="click" onclick="LoadAjax();"/>


</body>
</html>

SampleServlet .java

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SampleServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException
{
PrintWriter out;
try
{
out= res.getWriter();
out.print("<html> <head> <title> Response From Servlet </title>
</head> <body> <p> <h3> This Text Is Generated By Invoked Servlet
</h3> </body> </html>");
}
catch(IOException ie)
{
ie.printStackTrace();
}
}
}
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT:
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

10. WEB SERVICE

AIR LINE RESERVATION SYSTEM

STEPS:
1. OpenNetBeansIDECreate a New Project

2. FileNewProjectJava WebWeb ApplicationGive Your Project Name

Now One Solution Explorer Will Open in left Side of the Net Beans Tool

3. Right Click(On Your Project)NewWebService

4. Give Your Web service Name as MyWebService

5. Go to Design View Of Your MyWebService

6. Click Add OperationGive Your Operation Name As GetAirLineAdd Parameters and


Mention its Data Types

7. Click the Source of Your Web Service


CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

Here we Are Adding Two Parameters

1. From-java.lan.Satring

2. To-java.lan.Satring
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

PROGRAM:
MyWebService

package myp;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
*
* @author JuanAashish
*/
@WebService()
public class MyWebService
{
/**
* Web service operation
*/
@WebMethod(operationName = "Add")
public Integer Add(@WebParam(name = "a")
int a, @WebParam(name = "b")
int b)
{
//TODO write your implementation code here:
return a+b;
}
/**
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

* Web service operation


*/
@WebMethod(operationName = "GetAirLine")
public String GetAirLine(@WebParam(name = "From")
String From, @WebParam(name = "To")
String To)
{
String time="No Service";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:MyDsn");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select Time from Airline where
From='"+From+"' AND To='"+To+"'");
while(rs.next())
{
time=rs.getString(1);
}
stmt.close();
con.close();
}
catch(Exception e)
{}
return time;
}

/**
* Web service operation
*/
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

@WebMethod(operationName = "operation")
public String operation()
{
//TODO write your implementation code here:
return null;
}
}

CREATE A NEW JSP FOR CONNECTING WEB SERVICE:


BookTicketWS.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String from=request.getParameter("txta");
String to=request.getParameter("txtb");
myp.MyWebService objWS=new myp.MyWebService();
%>
<h1>Time is:<%=objWS.GetAirLine(from,to) %></h1>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

CREATE ONE HTML FOR ACCESSING FRONT PAGE


GetAirline.html
<html>
<head>
<title>Air Lines</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="GET" action=" http://localhost:8080/MyWeb/BookTicketWS.jsp">
From</br>
<input type="text" name="txta"/>
To</br>
<input type="text" name="txtb"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

TABLE DESIGN:
Table: Airline
CS2358 INTERNET PROGRAMMING LAB Reg.No:20609104329

OUTPUT

You might also like