Natchatran

NATCHATRAN

Natchatran Blogs includes Technical Tutorials, E-books, Notes, Lab Manual, Question Banks, Viva questions and Interview questions for engineering students, provides all study material for cse students.

-Natchatran(Prem Anandh.J)

Friday, December 27, 2013

CS67 - Internet Programming Lab Manual

                                     Ex :no 1 College Website design
PROGRAM:
Home.html
<!-- Ex:1 Website creation -->
<html>
<head>
<title>JPCOE</title>
</head>
<body bgcolor="black">
<center><h1><font face="stencil" color="yellow">NATCHATRAN ENGINEERING COLLEGE</h1>
<h7>Ayikudi,Tenkasi</h7></font>
<font face="stencil" color="Red"><h4>THIRUNELVELI</h4></font>

</center>
<hr>
<p>
 <font face="stencil" color="green">
   <center>
    <a href="home.html">Home</a>
    <a href="facilities.html">Facilities</a>
    <a href="courses.html">Courses</a>
    <a href="gallery.html">Gallery</a>
    <a href="contactus.html">Contact us</a>
   </center>
 </font>
</p>
<hr><h2><font face="stencil" color="white">Welcome to JPCOE</h2>
<br>
Be the Best....
<br>
<hr><center><font face="Comic Sans MS" color="white">powered by JPCOE.all rights reserved</font>
</body>
</html>
Facilities .html
<html>
<head>
<title>JPCOE</title>
</head>
<body>
<center><h1><font face="stencil" color="yellow"> NATCHATRAN ENGINEERING COLLEGE </font></h1>
<font face="stencil" color="Red"><h4>THIRUNELVELI</h4></font>
<h7>k.k.dist-629171</h7>
</center>
<hr>
<p>
 <font face="stencil" color="green">
   <center>
    <a href="home.html">home</a>
    <a href="facilities.html">Facilities</a>
    <a href="courses.html">courses</a>
    <a href="gallery.html">gallery</a>
    <a href="contactus.html">contact us</a>
   </center>
 </font>
</p>
<body bgcolor="black">
<hr><h2><font face="stencil" color="white"><br>FACILITIES<br></h2></font>
<br>
<ul><h4><font face="stencil" color="red">
<li>Excellent infrastructure
<li>Experienced Staff members
<li>Well Equpied lab
<li>ATM center
<li>Separate hostel for boys4 and girls
<li>English language lab
<li>Transport facility to varies Places
</ul>
<hr><center><font face="Comic Sans MS" color="white">powered by JPCOE.all rights reserved</font></center>
</body>
</html>
Gallery.html
<html>
<head>
<title>JPCOE</title>
</head>
<body>
<center><h1><font face="stencil" color="yellow"> NATCHATRAN ENGINEERING COLLEGE </font></h1>
<font face="stencil" color="Red"><h4>THIRUNELVELI</h4></font>
<h7>k.k.dist-629171</h7>
</center>
<hr>
<p>
 <font face="stencil" color="green">
   <center>
    <a href="home.html">home</a>
    <a href="facilities.html">Facilities</a>
    <a href="courses.html">courses</a>
    <a href="gallery.html">gallery</a>
    <a href="contactus.html">contact us</a>
   </center>
 </font>
</p>

<body bgcolor="black">
<hr><h2><font face="stencil" color="white"><br>PHOTO GALLERY<br></h2></font>
<br>
<center>
<img src="image1.jpg" alt="College photot" width="800" height="250"><br><br>
<img src="image2.jpg" alt="College photot" width="250" height="300">
</center>
<hr><center><font face="Comic Sans MS" color="white">powered by JPCOE.all rights reserved</font></center>
</body>
</html>
Courses.html
<html>
<head>
<title>JPCOE</title>
</head>
<body bgcolor="black">
<center><h1><font face="stencil" color="yellow"> NATCHATRAN ENGINEERING COLLEGE </font></h1>
<font face="stencil" color="Red"><h4>THIRUNELVELI</h4></font>
<h7>k.k.dist-629171</h7>
</center>
<hr>
<p>
 <font face="stencil" color="green">
   <center>
    <a href="home.html">home</a>
    <a href="facilities.html">Facilities</a>
    <a href="courses.html">courses</a>
    <a href="gallery.html">gallery</a>
    <a href="contactus.html">contact us</a>
   </center>
 </font>
</p>
<h1><font face="Arial Black" color="blue">COURSES</h1></font>
<h2><font face="Bookman Old Style" color="red">BE</h2>
<h3>
<ol>
 <li>CSE
 <li>ECE
 <li>IT
 <li>EEE
 <li>MECH
</ol>
</h3>
</font>
<h2><font face="Bookman Old Style" color="green">ME<br></h2>
<h3>
<ol>
<li>Network Engg.
<li>VLSI
</ol>
<h3>
</font>
<hr><br><center><font face="Comic Sans MS" color="white">powered by JPCOE. all rights reserved</font>
</body>
</html>
contactus.html
<html>
<head>
<title>JPCOE</title>
</head>
<body bgcolor="black">
<center><h1><font face="stencil" color="yellow"> NATCHATRAN ENGINEERING COLLEGE </font></h1>
<font face="stencil" color="Red"><h4>THIRUNELVELI</h4></font>
<h7>k.k.dist-629171</h7>
</center>
<hr>
<p>
 <font face="stencil" color="green">
   <center>
    <a href="home.html">home</a>
    <a href="facilities.html">Facilities</a>
    <a href="courses.html">courses</a>
    <a href="gallery.html">gallery</a>
    <a href="contact us.html">contact us</a>
   </center>
 </font>
</p>
<hr><h2><font face="Comic Sans MS" color="white">Contact us</h2>
<br>
<Address>Jp colege of Engineering<br>College Road<br>Ayikudi<br>Tenkasi<br>Ph No: 123456 <br><br>mail us to info@jpcoe.org<br></Address>
<br>
<hr><center>powered by JPCOE.all rights reserved</font>
</body>
</html>
Ex :no 2 Creation of image map


PROGRAM:
Imagemap.html
<!-- Ex:2 Creation of image map -->

<html>
<head><title>Image Map - India</title></head>
<body>
 <center><b><h4>Image Map - India</h4></b>
 <map id="india map" name="india map">
 <img src="india_map.jpg"  usemap="#india map">
  <area shape="circle" coords="200,175,10" alt="Delhi" href="delhi.html">
  <area shape="circle" coords="130,390,10" alt="Mumbai" href="mumbai.html">
  <area shape="circle" coords="385,370,10" alt="kolkatta" href="kolkatta.html">
  <area shape="circle" coords="255,535,10" alt="Chennai" href="chennai.html">
 </map>
 </center>
 <p><b>Note:</b> Click the hot spot to get the details of metro cities</p>
</body>
</html>
chennai.html
<html>
<head>
<title>CHENNAI</title>
</head>
<body bgcolor="green with black">
<center><font color="orange"size=4 face="lucida calligraphy">CHENNAI DETAILS</font></center>
<u><font color="yellow"size=4 face="arial">DESCRIPTION</font></u>
<ul><font color="violet"size=3 face="algerian">
<li>chennai is a capital of tamilnadu
<li>chennai is a big city of tamilnadu
</body>
</html>
delhi.html
<html>
<head>
<title>DELHI</title>
</head>
<body bgcolor="skyblue">
<center><font color="black" size="5" face="lucida calligraphy">DELHI</font></center>
<font color="orange" size="4" face="arial">DESCRPTION</font><br>
<font color="white" size="3" face="monotype corsiva">DELHI IS A CAPITAL OF INDIA.<br>
DELHI IS A BEAUTYFULL PLACE.</font>
</body>
</html>
kolkatta.html
<html>
<head>
<title>KOLKATTA</title>
</head>
<body bgcolor="skyblue">
<center><font color="black" size="5" face="lucida calligraphy">KOLKATTA</font></center>
<font color="orange" size="4" face="arial">DESCRPTION</font><br>
<font color="white" size="3" face="monotype corsiva">KOLKATTA IS A CAPITAL OF WEST BENGAL.<br>
KOLKATTA IS A HOTEST CITY.</font>
</body>
</html>
mumbai.html
<html>
<head>
<title>MUMBAI</title>
</head>
<body bgcolor="skyblue">
<center><font color="black" size="5" face="lucida calligraphy">MUMBAI</font></center>
<font color="orange" size="4" face="arial">DESCRPTION</font><br>
<font color="white" size="3" face="monotype corsiva">MUMBAI IS A CAPITAL OF MAHARASTRA.<br>
 MUMBAI IS A BIG CITY.</font>
</body>
</html>

Ex: 3 Creation of Embedded style sheets
PROGRAM:
EmbeddedCSS.html
<!-- Ex: 3 Creation of Embedded style sheets -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>     <title>Embedded style sheet</title> 
 <style type="text/css">
  h1
  {
   font-family:Arial;
   color:green
  }
  h2 {
   font-family:Arial;
   color:red;
   left:20px
  }
  h3{
   font-family:arial;
   color:blue;
  }
  p{
   font-size:14pt;
   font-family:verdana
  }
  #mystyle1
  {
   font-family:Comic Sans MS;
   color:yellow;
   font-size:15
  }
 </style>
</head>
<body>
 <h1>
  <center>    This page is created using Embedded Style Sheet     </center>
 </h1>
 <h2>
  This line is aligned left and red colored.
 </h2>
 <p>   The embedded style sheet is the most commonly used style sheet. This paragraph is written    in Verdana font with font size of 14. </p>
 <h3> This is a blue <a href=”colorname.html”>colored</a> line.       </h3>
 <div class="mystyle1">hai </div>
</body>
</html>
Ex: 4 Creation of External style sheets

PROGRAM:
Ex4CSS.css
<!--Ex: 4 Creation of External style sheets-->
h1
{
 font-family:Arial
}
h2
{
 font-family:times new roman;
 color:red;
left:20px
}
h3
{
font-family:arial;
color:blue;
}
p         
{
 font-size:14pt;
 font-family:Monotype Corsiva
}

Ex4CSS.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                        <link rel="stylesheet" type="text/css" href="ex4CSS.css" />
                        </head>
                        <body>
            <h1 class="special"> <center> This page is created using External Style
               Sheet</center>  </h1>
                                        <h2>
                                                             This line is aligned left and red colored.
                                                </h2>
                                                <p>The External style sheet is the compact representation of Cascading  Style Sheets.
                                        This paragraph is written in Monotype Corsiva font with font size of 14.               </p>
                                        <h3>
                                                          This is a blue <a href=”colorname.html”>colored</a> line.
                                                </h3>
                        </body>
</html>
Ex:5 Validating Web Form Controls using DHTML

PROGRAM:
ApplicationForm.html
<!--  Ex:5 Validating Web Form Controls using DHTML -->
<html>
 <head>
 <title>The Student Registration Form</title>
 <script type="text/javascript">
  function validate()
  {
   var i;
   var name_str=document.my_form.name;
   var phoneID=document.my_form.ph_txt;
   var ph_str=document.my_form.ph_txt.value;
   var str=document.my_form.Email_txt.value;
   if((name_str.value==null)||(name_str.value==""))
   {
    alert("Enter some name");
    return false;
   }
   if(document.my_form.Age_txt.value=="")
   {
    alert("Enter the Age");
    return false;
   }
   if((document.my_form.Age_txt.value<"5")&&(document.my_form.Age_txt.value>"21"))
   {
    alert("Invalid Age");
    return false;
   }
   if(ph_str.length<1 ||ph_str.length>11)
   {
    alert("Invalid length of Phone Number");
    return false;
   }
   for (i = 0; i < ph_str.length; i++)
   {  
    var ch = ph_str.charAt(i);
    if (((ch < "0") || (ch > "9")))
    {
     alert("Invalid Phone Number");
     phoneID.focus();
     return false;
    }
   }
   var index_at=str.indexOf("@");
   var len=str.length;
   var index_dot=str.indexOf(".");
   var emailID=document.my_form.Email_txt;
   if ((emailID.value==null)||(emailID.value==""))
   {
    alert("Please Enter your Email ID");
    emailID.focus();
    return false;
   }
   if (str.indexOf("@")==-1)
   {
    alert("Invalid E-mail ID");
    return false;
   }
   if (str.indexOf(".")==-1 || str.indexOf(".")==0 || str.indexOf(".")==index_at)
   {
    alert("Invalid E-mail ID");
    return false;
   }
   if (str.indexOf("@",(index_at+1))!=-1)
   {
    alert("Invalid E-mail ID");
    return false;
   }
   if (str.indexOf(" ")!=-1)
   {
    alert("Invalid E-mail ID");
    return false;
   }
   if (!document.my_form.group1[0].checked && !document.my_form.group1[1].checked)
   {
    alert("Please Select Sex");
    return false;
   }
   alert("Registered Successfully");
   return true;
  }                                                       
 </script>
 </head>
 <body bgcolor=aqua>
 <center><h3>Application Form</h3></center>
 <form name="my_form" onsubmit="validate()">
  <strong>Name:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong>
  <input type=text name=name><br/><br/>
  <strong>Age:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<strong>
  <input type=text name=Age_txt><br/><br/>
  <strong>Phone No:&nbsp</strong>
  <input type=text name=ph_txt><br/><br/>
  <strong>Email:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong>
  <input type=text name=Email_txt><br/><br/>
  <strong>Sex:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </strong>
  <input type="radio" name="group1" value="Male">Male&nbsp&nbsp&nbsp&nbsp
  <input type="radio" name="group1" value="Female">Female<br/><br/><br/>
  <strong>Hoby: </strong>  &nbsp&nbsp
  <input type="checkbox" name ="option1" value="Singing">Singing<br/>
  &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
  <input type="checkbox" name ="option1" value="Reading">Reading<br/>
  &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
  <input type="checkbox" name ="option1" value="T.V.">Watching T.V<br/>
  <br/><br/>
  <strong>Country:</strong>
  <select name="My_Menu">
   <option value="India">India</option>
   <option value="China">China</option>
   <option value="Nepal">Nepal</option>
  </select>
  <center>
    <input type="submit" value="Submit"></br>
  </center>
 </form>
 </body>
</html>

Ex:6 Creation of Color palette

PROGRAM:
ColorPalette.java
// Ex:6 Creation of Color palette
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*<applet code="ColorPalette" width=400 height=400>
</applet>*/
public class ColorPalette extends Applet implements ItemListener
{
 int currcolor=5;
 int flag=1;
 String text="Click any of the buttons";
 Button buttons[]=new Button[5];
 String colours[]={"Red","Blue","Green","Yellow","Magenta"};
 Image img;
 CheckboxGroup cbg=new CheckboxGroup();
 Checkbox box1=new Checkbox("Background Color",cbg,true);
 Checkbox box2=new Checkbox("Text Color",cbg,false);
 Checkbox box3=new Checkbox("Loading Image",cbg,false);
 public void init()
 {
  for(int i=0;i<5;i++)
  {
   buttons[i]=new Button(" ");
   add(buttons[i]);
  }
  buttons[0].setBackground(Color.red);
  buttons[1].setBackground(Color.blue);
  buttons[2].setBackground(Color.green);
  buttons[3].setBackground(Color.yellow);
  buttons[4].setBackground(Color.magenta);
  add(box1);
  add(box2);
  add(box3);
  box1.addItemListener(this);
  box2.addItemListener(this);
  box3.addItemListener(this);
 }
 public void itemStateChanged(ItemEvent ev)
 {
  if(box1.getState()==true)
   flag=1;
  else if(box2.getState()==true)
  {
   text="Default color is black";
   flag=2;
  }
  else if(box3.getState()==true)
  {
   img=getImage(getDocumentBase(),"prem.jpg");
   flag=3;
  }
  repaint();
 }
 public void paint(Graphics g)
 {
  if(flag==2)
  {
   g.drawString(text,30,100);
   switch(currcolor)
   {
    case 0:
     g.setColor(Color.red);
     break;
    case 1:
     g.setColor(Color.blue);
     break;
    case 2:
     g.setColor(Color.green);
     break;
    case 3:
     g.setColor(Color.yellow);
     break;
    case 4:
     g.setColor(Color.magenta);
     break;
    case 5:
     g.setColor(Color.black);
     break;
   }
   g.drawString(text,30,100);
  }
  else if(flag==1)
  {
   g.drawString(text,30,100);
   switch(currcolor)
   {
    case 0:
     setBackground(Color.red);
     break;
    case 1:
     setBackground(Color.blue);
     break;
    case 2:
     setBackground(Color.green);
     break;
    case 3:
     setBackground(Color.yellow);
     break;
    case 4:
     setBackground(Color.magenta);
     break;
    case 5:
     setBackground(Color.white);
     break;
   }
  }
  else if(flag==3)
  {
   g.drawImage(img,20,90,this);
  }
 }
 public boolean action(Event e,Object o)
 {
  for(int i=0;i<5;i++)
  {
   if(e.target==buttons[i])
   {
    currcolor=i;
    text="You have chosen "+colours[i];
    repaint();
    return true;
   }
  }
  return false;
 }
}

OUTPUT:

    C:\jdk1.6.0_05\bin>javac ColorPalette.java
    C:\jdk1.6.0_05\bin>appletviewer ColorPalette.java
           



Ex: 7 Creation of Java Servlet
PROGRAM:
ex7servlet.java
// Ex: 7 Creation of Java Servlet
import java.io.*;
import java.util.*;
import javax.servlet.*;
import java.net.*;
import javax.servlet.http.*;
public class ex7servlet extends GenericServlet
{
 public void service(ServletRequest req,ServletResponse res) throws ServletException,IOException
 {
  PrintWriter out=res.getWriter();
  Enumeration en=req.getParameterNames();
  out.println("Student Details\n");
  while(en.hasMoreElements())
  {
   String name_received=(String)en.nextElement();
   out.print(name_received+ " = ");
   String value_received=req.getParameter(name_received);
   out.println(value_received);
   out.println(" ");
  }
  out.close();
 }
}

invokeServlet.html
<html>
<head>
<title>Student Information Form</title>
</head>
<body>
<center>
<form name="form1"
action="http://localhost:8084/Ex7_Servlet/ex7servlet">
<h3>Enter student information in following fields -</h3>
<table>
<tr>
<td><b>Roll Number</b></td>
<td><input type="text" name="Roll Number" size="25" value=" "></td>
</tr>
<tr>
<td><b>Student Name</b></td>
<td><input type="text" name="Student Name" size="25" value=" "></td>
</tr>
<tr>
<tr>
<td><b>Student Address</b></td>
<td><input type="text" name="Address" size="50" value=" "></td>
</tr>
<tr>
<td><b>Phone</td>
<td><input type="text" name="Phone" size="25" value=" "></td>
</tr>
<tr>
<td><b>Total Marks</td>
<td><input type="text" name="Total Marks" size="10" value=" "></td>
</tr>
</table>
<input type="submit" value="submit">
</form>
</center>
</body>
</html>

Ex: 8. Simple XML Document using XSL 

PROGRAM:
SimpleXml.xsl
<!-- Ex: 8. Simple XML Document using XSL  -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
  <h2>Students Database</h2>
  <table border="1">
    <tr bgcolor="gray">
      <th>Name</th>
      <th>Address</th>
      <th>Standard</th>
      <th>Marks</th>
    </tr>
    <xsl:for-each select="Student/Person-Details">
    <tr bgcolor="pink">
      <td><xsl:value-of select="name"/></td>
      <td><xsl:value-of select="address"/></td>
      <td><xsl:value-of select="branch"/></td>
      <td><xsl:value-of select="marks"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
SimpleXml.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="SimpleXml.xsl"?>
<Student>
  <Person-Details>
            <name>Yogi</name>
            <address>Pune</address>
            <branch>CSE</branch>
            <marks>85 percent</marks>
  </Person-Details>
  <Person-Details>
            <name>Naren</name>
            <address>Chennai</address>
            <branch>IT</branch>
            <marks>90 percent</marks>
  </Person-Details>
  <Person-Details>
            <name>Varun</name>
            <address>Mumbai</address>
            <branch>MECH</branch>
            <marks>80 percent</marks>
  </Person-Details>
  <Person-Details>
            <name>Nithya</name>
            <address>Delhi</address>
            <branch>CSE</branch>
            <marks>77 percent</marks>
  </Person-Details>
</Student>

Ex: 9. Web Programming using AJAX 

PROGRAM:
Index.html
<!--    Ex: 9. Web Programming using AJAX  -->
<html>
<head>
<title> Ajax at work </title>
<script language = "javascript">
 var XMLHttpRequestObject = false;
 if (window.XMLHttpRequest)
 {
  XMLHttpRequestObject = new XMLHttpRequest();
 }
 else if (window.ActiveXObject)
 {
  XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
 }
 function getData(dataSource, divID)
 {
  if(XMLHttpRequestObject)
  {
   var obj = document.getElementById(divID);
   XMLHttpRequestObject.open("GET", dataSource);
   XMLHttpRequestObject.onreadystatechange = function()
   {
    if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
    {
     obj.innerHTML = XMLHttpRequestObject.responseText;
    }
   }
   XMLHttpRequestObject.send(null);
  }
 }
</script>
</head>
<body>
<h1> Fetching data with Ajax </h1>
<form>
 <input type = "button" value = "Display Message" onclick = "getData('data.txt', 'targetDiv')">
</form>
<div id="targetDiv">
<p>The fetched data will go here.</p>
</div>
</body>
</html>

Data.txt
This is the new data


Ex: 10.  On-line Examination using JSP  

PROGRAM
index.jsp
<!--   Ex: 10.  On-line Examination using JSP   -->
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
 <head>
  <title>Online Examination</title>
  <script language="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();
    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>NATCHATRAN ENGINEERING COLLEGE</h1>
   <h2>OnLine Examination - Web Technology</h2>
  </center>
  <form action="Exam.jsp" method="post" name="entry" onSubmit="return validation(this)">
   <input type="hidden" value="list" name="action">
   <strong>Seat Number:</strong><input type="text" name="Seat_no"><br><br>
   <strong>Name:</strong>><input type="text" name="Name" size="50"><br><br>
   <b>Total Marks:10(5*2=10) </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Time: 15 Min.</b>
   <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>
   <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>
   <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>
   <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>
   <br/>
   <b>5. HTTP is a statefull protocol</b><br/>
   <input type="radio" name="group5" value="True">True
   <input type="radio" name="group5" value="False">False<br>
   <hr/>                      
   <center>
   <input type = "submit" value="Submit">
   <input type = "reset" value="Clear"><br><br>
   </center>
  </form>
 </body>
</html>
Exam.jsp
<%@ 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;
  Statement stmt;
  ResultSet rs;
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  String url = "jdbc:odbc:StudentDB1";
  connect = DriverManager.getConnection(url, " ", " ");
  SeatNum = request.getParameter("Seat_no");
  Name = request.getParameter("Name");
  ans1 =request.getParameter("group1");        
  if(ans1.equals("True"))
   a1=2;
  else 
   a1=0;             
  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 StudentTable (" + "Seat_no,Name,Marks" +  ") VALUES ('" +SeatNum + "', '" + Name + "', '"+Total+ "')";
  int result = stmt.executeUpdate(query);  
  stmt.close();        
  stmt = connect.createStatement();
  query = "SELECT * FROM StudentTable WHERE Name="+"'"+Name+"'";
  rs = stmt.executeQuery(query);
%>
<html>
 <head><title>Student Mark List</title></head>
 <body bgcolor=khaki>
  <center>
  <h2>Students Marksheet</h2>
  <h3>Name of the College:NATCHATRAN ENGINEERING COLLEGE</h3>
  <h4>Department:CSE</h4>
  <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(1)%></td>
    <td> <%=rs.getString(2)%></td>
    <td> <%=rs.getString(3)%></td>
   </tr>
   <%
     }
     rs.close();
     stmt.close();
     connect.close();
   %>
  </table>
  </center>
  <br/> <br/><br/>                  
  <b>Date:<%=new java.util.Date().toString() %><br/><br/>
  <b>Signature: <strike>prem</strike> <b><br/><br/>
  <a href="http://localhost:8084/onlineExam/index.jsp">Click here to go back</a>
 </body>

</html>

No comments: