0% found this document useful (0 votes)
3 views76 pages

Interactive Indian State Map Guide

The document contains HTML code for a website with an image map linking to various state pages in India, including Tamil Nadu, Karnataka, Andhra Pradesh, and Kerala, each detailing area, capital, language, and population. Additionally, there are multiple HTML files for an online book store, including login, registration, catalog, payment, and profile pages, with JavaScript for form validation. The servlet code handles user login and registration, responding with appropriate messages based on the input credentials.

Uploaded by

GOKUL.S.S S.s
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)
3 views76 pages

Interactive Indian State Map Guide

The document contains HTML code for a website with an image map linking to various state pages in India, including Tamil Nadu, Karnataka, Andhra Pradesh, and Kerala, each detailing area, capital, language, and population. Additionally, there are multiple HTML files for an online book store, including login, registration, catalog, payment, and profile pages, with JavaScript for form validation. The servlet code handles user login and registration, responding with appropriate messages based on the input credentials.

Uploaded by

GOKUL.S.S S.s
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

PROGRAM:

[Link]
<HTML>
<HEAD>
<TITLE>Image Map</TITLE> </HEAD>
<BODY>
<img src="india_map.jpg" usemap="#metroid" ismap="ismap" > <map name="metroid"
id="metroid">
<area href="[Link]" shape="circle" coords="208,606,50" title="TamilNadu"/>
<area href="[Link]" shape="rect" coords = "130,531,164,535" title ="Karnataka" />
<area href="[Link]" shape="poly" coords =
"227,490,238,511,230,536,198,535,202,503" title ="Andhra Pradesh" />
<area href="[Link]" shape="rect" coords = "154,606,166,621" title ="Kerala" /> </map>
</BODY>
</HTML>
[Link]
<HTML><HEAD>
<TITLE>About Tamil Nadu</TITLE>
</HEAD>
<BODY>
<CENTER><H1>Tamil Nadu</H1></CENTER> <HR>
<UL>
<LI>Area : 1,30,058 Sq. Kms.</LI>
<LI>Capital : Chennai</LI>
<LI>Language : Tamil</LI>
<LI>Population : 6,21,10,839</LI> </UL><hr>
<a href='[Link]'>India Map</a>
</BODY>
</HTML>

[Link]
<HTML>
<HEAD>
<TITLE>About Karnataka</TITLE> </HEAD>
<BODY>
<CENTER><H1>Karnataka</H1></CENTER>
<HR>

<UL>
<LI>Area : 1,91,791 Sq. Kms</LI>
<LI>Capital : Bangalore</LI>
<LI>Language : Kannada</LI>
<LI>Population : 5,27,33,958</LI>
</UL>
<hr>
<a href='[Link]'>India Map</a>
</BODY>
</HTML>

[Link]
<HTML>
<HEAD>
<TITLE>About Andhra Pradesh</TITLE> </HEAD>
<BODY>
<CENTER><H1>Andhra Pradesh</H1></CENTER> <HR>
<UL>
<LI>Area : 2,75,068 Sq. Kms</LI>
<LI>Capital : Hyderabad</LI>
<LI>Language : Telugu</LI>
<LI>Population : 7,57,27,541</LI>
</UL>
<hr>
<a href='[Link]'>India Map</a>
</BODY>
</HTML>

[Link]
<HTML>
<HEAD>
<TITLE>About Kerala</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Kerala</H1></CENTER>
<HR>
<UL>
<LI>Area : 38,863 Sq. Kms.</LI>
<LI>Capital : Thiruvananthapuram</LI>
<LI>Language : Malayalam</LI>
<LI>Population : 3,18,38,619</LI>
</UL>
<hr>
<a href='[Link]'>India Map</a>
</BODY></HTML>

OUTPUT:
RESULT:
PROGRAM:

[Link]:
h3
{
font-family:arial;
font-size:20;
color:cyan
}
table{
border-color:green
}
td
{
font-size:20pt;
color:magenta
}

HTML CODE:
<html>
<head>
<h1>
<center>ALL STYLE SHEETS</center>
</h1>
<title>USE of INTERNAL and EXTERNAL STYLESHEETS </title>
<link rel="stylesheet" href="[Link]" type="text/css">
<style type="text/css">
.vid
{
a
n
a
;
}
.ani f
{ o
f n
o t
n -
t s
- t
f y
a l
m e
i :
l i
y t
: a
v l
e i
r c
d ;
c
o
l
o
r
:
r
e
d
;
text-align:center

f
o
n
t
-
f
a
m
i
l
y
:
t
a
h
o
m
a
;

f
o
n
t
-
s
t
y
l
e
:
i
t
a
l
i
c
;
b
l
} u
font e
{ ;
font-size:20

}
ul list-style-type:circle
{

}
p f
{ o
n
t
} -
hr f
{ a
m
} i
l
font-size:20;
y
text-align:center; :

g
e
f o
o r
n g
t i
- a
f ,
a
m s
i e
l r
y i
: f
g ;
e
o f
r o
g n
i t
a -
; s
i
c z
o e
l :
o
r x
: -
s ;
m
a
l
l color: #ff9900; height: 1px
a:hover
{
color: #ff0000;
text-decoration: none
}
</style>
</head>
<body>
<h1 style="color:blue;margin-left:30px;">Welcome</h1> //In-line style Sheet
<ol style="list-style-type:lower-alpha">

<b>[Link]’s College of Engineering and Technology </b>


<br>
<br>
<br>
<li> EEE</li>

<li> ECE </li>


<li> MECH</li>
<li> CSE</li>
</ol>
<p style="font-size:20pt;color:purple">Details</p>
<p class="ani">[Link]’s College <br>It is approved by AICTE(All India Council for
Technical Education). It is affliated to Anna University.<br></p>
<h2 class="vid"> [Link]’s college of engineering </h2> <br>
<font>It is an ISO certified Institution
</font>
<br>
<br>
<font>
<h2>List of Courses offered</h2>
<ul>

<li>Computer Science and Engineering</li>


<li>Ece</li>
<li>mech</li>
<li>eee</li>
</ul>
</font>
<h3>Results of cse students</h3>
<table width="100%" cellspacing="2" cellpadding="2" border="5"> <tr>
<th>[Link]</th> <th>MARKS</th> <th>RESULT</th>
</tr>
<tr>
<td align="center">Suppriya</td> <td
align="center">100</td>
</tr> <td align="center">pass</td>
<tr>

<td align="center">Devishree</td> <td


</tr> align="center">99</td>
<tr> <td align="center">pass</td>

<td align="center">Vinayagam</td> <td


align="center">98</td>
<td align="center">pass</td> </tr>
</table>
</body>
</html>

OUTPUT:

RESULT:
PROGRAM AND OUTPUT :

[Link]:
<html>
<head>
<title> ONLINE BOOK STORES</title>
</head>
<body bgcolor="pink">
<marquee><h1 align=”center”><b><u><font color="white">
ONLINE BOOK STORAGE</u></font>
</b></h1></marquee>
<H2 ALIGN="CENTER">
<b><p><U><FONT COLOR="PURPLE">Welcome to online book storage.
Press login if you are having id otherwise press registration.</U></FONT></p></b></H2>
<H2> <FONT COLOR="WHITE"></FONT></H2>
<H3 ALIGN="CENTER">
<A HREF="[Link]"><BR><BR><FONT COLOR="black"><ITALIC>REGISTRATION
FORM</FONT></ITALIC><BR><BR>
<BR><BR><A HREF="[Link]"><FONT COLOR="black"><ITALIC>USER
PROFILE</FONT></ITALIC><BR>
<BR><BR><A HREF="[Link]"><FONT COLOR="black"><ITALIC>USER
LOGIN</FONT></ITALIC><BR>
<BR><BR><A HREF="[Link]"><FONT COLOR="black"><ITALIC>BOOKS
CATALOG</FONT></ITALIC><BR>
<BR><BR><A HREF="[Link]"><FONT
COLOR="black"><ITALIC>PAYMENT</FONT></ITALIC><BR>
<BR><BR><A HREF="[Link]"><FONT COLOR="black"><ITALIC>ORDER
CONFIRMATION</H3></FONT></ITALIC><BR>
</body>
</html>

[Link]:
<html>
<body bgcolor=”blue”><br><br><br>
<script language=”javascript”>
function validate()
{
var flag=1; if([Link]==""||
[Link]=="")
{
alert("LoginId and Password must be filled")
flag=0;
}
if(flag==1)
{
alert(“VALID INPUT”);
[Link]("[Link]","right");
}
else
{
alert(“INVALID INPUT”);
//[Link]();
}
}
</script>
<form name=”myform”>
<div align=”center”><pre>
LOGIN ID:<input type=”text” name=”id”><br>
PASSWORD:<input type=”password” name=”pwd”>
<br><br>
</pre>
<input type=”button” value=”ok” onClick=”validate()”>
<input type=”reset” value=”clear”>
</div>
</form>
</body>
</html>

[Link]:
<html>
<body bgcolor=”blue”><br><br>
<script language=”javascript”>
var str=[Link];
var x;
if(flag==1)
{

}
else
{

}
}alert("VALID INPUT");

alert("INVALID INPUT");
[Link](); </script>
<form name="myform">
<div align="center"><pre>
NAME :<input type="text" name="name"><br>
ADDRESS :<input type="type" name="addr"><br>
CONTACT NUMBER:<iput type="text" name="phno"><br>
LOGINID :<input type="text" name="id"><br>
PASSWORD :<input type="password" name="pwd"></pre><br><br>
</div>

<br><br>
<div align="center">
<input type="submit" value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;
<input type="reset" value="clear">
</form></body></html>

[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<div align="center">
<pre>
BOOK TITLE:<input type="text" name="title"><br>
</pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" name="button1">
<input type="reset" value="clear" name="button2">
</body>
</html>

[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>
TITLE :<input type="text" name="title"><br>
[Link] BOOKS :<input type="text" name="no"><br>
COST OF BOOK:<input type="text"name="cost"><br>
DATE :<input tpe="text" name="date"><br></pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" name="button1">
<input type="reset" value="clear" name="button2">
</body>
</html>

[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">
function validate()
{
var flag=1;
if([Link]==""||
[Link]==""||
[Link]==""||
[Link]=="")
{
flag=0;
}
var str=[Link];
var x;
for(var i=0;i<[Link];i++)
{
x=[Link](i,1); if(!
(x<=9))
{
flag=0;
break;
}
}
str=[Link]
; for(var i=0;i<[Link];i++)
{
x=[Link](i,1); if(!
(x<=9))
{
flag=0;
break;
}
}
if(flag==1)
{
}
} alert("VALID INPUT");
else
{

alert("INVALID INPUT");
} [Link]();
</script>
<form name="myform">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>
PASSWORD :<input type="password" name="pwd"><br>
AMOUNT :<input type="text" name="amount"><br>
CREDITCARDNUMBER:<input type="PASSWORD" name="num+"><br></pre><br><br>
</div>
<br><br><div align="center">
<input type="submit" value="ok" onClick="validate()">
<input type="reset" value="clear">
</form>
</body>
</html>

[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<script type="text/javascript">
function validate()
{
var flag=1;
if([Link]==""||
[Link]=="")
{
flag=0;
}
if(flag==1)
{
}
} alert("VALID INPUT");
else
{

alert("INVALID INPUT");
} [Link]();
</script>
<form name="myform">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>
PASSWORD:<input type="password" name="pwd"></pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" onClick="validate()">
<input type="reset" value="clear" >
</form>
</body></html>
RESULT:
PROGRAM:

[Link]:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MySrv extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

[Link]("text/html");
PrintWriter out = [Link]();
[Link]("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
[Link]("<HTML>");
[Link](" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
[Link](" <BODY>");

//Getting HTML parameters from Servlet

String username=[Link]("uname");
String password=[Link]("pwd");
if(([Link]("user")) && ([Link]("pswd")))
{
[Link](" <h1> Welcome to "+username);
}
else
{
[Link](" <h1> Registration success ");
[Link](" <a href='./[Link]'> Click for Home page </a>");
}
[Link](" </BODY>");
[Link]("</HTML>");
[Link]();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost( request,response);
}
}

[Link]:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY bgcolor='#e600e6'>
<form action='./MySrv' method="post">
<center> <h1> <u> Login Page </u></h1>
<h2> Username : <input type="text" name="uname"/>
Password : <input type="password" name="pwd"/>
<input type="submit" value="click me"/>
</center>
</form>
</body>
</HTML>

[Link]:
<web-app>
<servlet>
<servlet-name>MySrv</servlet-name>
<servlet-class>MySrv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MySrv</servlet-name>
<url-pattern>/MySrv</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
OUTPUT:

RESULT:
PROGRAM:
[Link]:

<html>
<body bgcolor = "cyan">
<center>
<h1>WELCOME TO REGISTRATION PAGE</h1>
<form action="./registerone" METHOD="post">
Name: <input type="text" name = "name"><br><br>
Password: <input type="password" name="password"><br><br>
PROFESSION:
<select name="profession">
<option value="engineer">ENGINEER</option>
<option value="teacher">TEACHER</option>
<option value="businessman">BUSINESSMAN</option>
</select><br><br>
<input type="submit" value="REGISTER">
</form>
</center>
</body>
</html>

[Link]
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>RegistrationServletOne</servlet-name>
<servlet-class>RegistrationServletOne</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationServletOne</servlet-name>
<url-pattern>/registerone</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>RegistrationServletTwo</servlet-name>
<servlet-class>RegistrationServletTwo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationServletTwo</servlet-name>
<url-pattern>/registertwo</url-pattern>
</servlet-mapping>
</web-app>

[Link]:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class RegistrationServletOne extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String name = [Link]("name");
String password = [Link]("password");
String profession = [Link]("profession");
[Link]("text/html");
PrintWriter out = [Link]();
[Link]("<html><body bgcolor = wheat>");
[Link]("<center>");
[Link]("<h1>COMPLETE THE REGISTRATION</h1>");
[Link]("<form action = ./registertwo method = post");
[Link]("<input type = hidden name = name value =" + name + ">");
[Link]("<input type = hidden name = password value =" + password + ">");
[Link]("<input type = hidden name = profession value =" + profession + ">");
[Link]("EMAIL ID:<input type =text name = email><br><br>");
[Link]("PHONE NO:<input type =text name = cell><br><br>");
[Link]("<input type =submit value=registernow>");
[Link]("</center>");
[Link]("</body></html>");
[Link]();
}
}

[Link]
a import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class RegistrationServletTwo extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String name = [Link]("name");
String password = [Link]("password");
String profession = [Link]("profession");
String email = [Link]("email");
String cell = [Link]("cell");
[Link]("text/html");
PrintWriter out = [Link]();
[Link]("<html><body bgcolor = wheat>");
[Link]("<center>");
[Link]("<h1>REGISTRATION SUCCESSFUL </h1>");
[Link]("</center>");
[Link]("</body></html>");
[Link]();
}
Output:
RESULT:
[Link]: SESSION TRACKING A HIT COUNT
Date:

PROGRAM:

[Link]
import [Link].*;
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;

public class PageHitCounter extends HttpServlet

{ private int hitCount;

public void init() {


// Reset hit counter.
hitCount = 0;
}

public void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

// Set response content type


[Link]("text/html");

// This method executes whenever the servlet is hit


// increment hitCount
hitCount++;
PrintWriter out = [Link]();
String title = "Total Number of Hits";
String docType = "<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";

[Link](docType +
"<html>\n" +
"<head><title>" + title + "</title></head>\n" +
"<body bgcolor = \"#f0f0f0\">\n" +
"<h1 align = \"center\">" + title + "</h1>\n" +
"<h2 align = \"center\">" + hitCount + "</h2>\n" +
"</body>
</html>"
);
}

public void destroy() {


// This is optional step but if you like you
// can write hitCount value in your database.
}
}

[Link]
<servlet>
<servlet-name>PageHitCounter</servlet-name>
<servlet-class>PageHitCounter</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>PageHitCounter</servlet-name>
<url-pattern>/PageHitCounter</url-pattern>
</servlet-mapping

OUTPUT:

RESULT:
[Link]: ON-LINE EXAMINATION USING SERVLETS
Date:

PROGRAM:

Servlet Code:
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class StudentServlet3 extends HttpServlet
{
String message,Seat_no,Name,ans1,ans2,ans3,ans4,ans5; int Total=0;
Connection connect; Statement stmt=null; ResultSet rs=null;
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletExcep-
tion,IOException
{
try
{
String url="jdbc:odbc:NEO"; [Link]("[Link]");
connect=[Link](url," "," "); message="Thank you for participating in online
Exam";
}
catch(ClassNotFoundException cnfex){ [Link]();
}
catch(SQLException sqlex){ [Link]();
}
catch(Exception excp){ [Link]();
}
Seat_no=[Link]("Seat_no"); Name=[Link]("Name");
ans1=[Link]("group1"); ans2=[Link]("group2");
ans3=[Link]("group3"); ans4=[Link]("group4");
ans5=[Link]("group5"); if([Link]("True"))
Total+=2;
if([Link]("False"))
Total+=2;
if([Link]("True"))
Total+=2;
if([Link]("False"))
Total+=2;
if([Link]("False"))
Total+=2; try
{
Statement stmt=[Link]();
String query="INSERT INTO student("+"Seat_no,Name,Total"+") VAL-
UES('"+Seat_no+"','"+Name+"','"+Total+"')";
int result=[Link](query); [Link]();
}catch(SQLException ex){
}
[Link]("text/html"); PrintWriter out=[Link](); [Link]("<html>");
[Link]("<head>"); [Link]("</head>"); [Link]("<body bgcolor=cyan>");
[Link]("<center>"); [Link]("<h1>"+message+"</h1>\n");
[Link]("<h3>Yours results stored in our database</h3>"); [Link]("<br><br>");
[Link]("<b>"+"Participants and their Marks"+"</b>"); [Link]("<table border=5>");
try
{
Statement stmt=[Link](); String query="SELECT * FROM student";
rs=[Link](query); [Link]("<th>"+"Seat_no"+"</th>");
[Link]("<th>"+"Name"+"</th>"); [Link]("<th>"+"Marks"+"</th>"); while([Link]())
{
[Link]("<tr>");
[Link]("<td>"+[Link](1)+"</td>");
[Link]("<td>"+[Link](2)+"</td>");
[Link]("<td>"+[Link](3)+"</td>");
[Link]("</tr>");
}
[Link]("</table>");
}
catch(SQLException ex){ } finally
{
try
{
if(rs!=null)
[Link](); if(stmt!
=null) [Link]();
if(connect!=null)
[Link]();
}
catch(SQLException e){ }
}
[Link]("</center>");
[Link]("</body></html>");
Total=0;
}}

HTML Code:
<html><head><title>Database Test</title></head> <body>
<center><h1>Online Examination</h1> </center>
<form action="[Link]" method="POST"> <div align="left"><br></div>
<b>Seat Number:</b> <input type="text" name="Seat_no"> <div align="Right">
<b>Name:</b> <input type="text" name="Name" size="50"><br> </div>
<br><br>
<b>1. Every host implements transport layer.</b><br/> <input type="radio" name="group1"
value="True">True <input type="radio" name="group1" value="False">False<br>
<b>2. It is a network layer's responsibility to forward packets reliably from source to destina-
tion</b><br/>
<input type="radio" name="group2" value="True">True
<input type="radio" name="group2" value="False">False<br>
<b>3. Packet switching is more useful in bursty traffic</b><br/> <input type="radio" name="group3"
value="True">True<input type="radio" name="group3" value="False">False<br> <b>4. A phone
network uses packet switching</b><br/> <input type="radio" name="group4" value="True">True
<input type="radio" name="group4" value="False">False<br>
<b>5. HTML is a Protocol for describing web contents</b><br/> <input type="radio" name="group5"
value="True">True
<input type="radio" name="group5" value="False">False<br> <br><br><br>
<center>
<input type="submit" value="Submit"><br><br> </center>
</form></body></html>

OUTPUT:

RESULT:
[Link]: CONVERSION OF STATIC WEBPAGES INTO DYNAMIC USING SERVLETS
Date:

PROGRAM:

[Link]
<!DOCTYPE html>
<html>
<head>
<body>
<form action="[Link] method="post">
Enter username:
<input type="text" value="" name="User"><br><br>
enter password:
<input type="password" value="" name="password"><br><br>
enter card ID:
<input type="text" value="" name="CardID"><br><br>
<input type="submit" value="login">
</form>
</body>
</html>
[Link]
package shopping;
import [Link].*;
import [Link].*;
import [Link].*;
public class LoginServlet extends HttpServlet
{
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException,IOException
{
[Link]("text/html");
PrintWriter out=[Link]();
String usr=[Link]("User");
String pwd=[Link]("password");
String card=[Link]("CardID");

boolean flag=true;
String[] userID=getInitParameter("usernames").split(",");
String[] password=getInitParameter("passwords").split(",");
String[] cardids=getInitParameter("cardIDs").split(",");
int i; for(i=0;i<[Link];i+
+)
{
if(userID[i].equals(usr) && password[i].equals(pwd)&&cardids[i].equals(card))
{
flag=false;
Cookie cookie1=new
Cookie("CurrentUser",usr); Cookie
cookie2=new Cookie("CreditCard",card);
[Link](cookie1);
[Link](cookie2);
[Link]("<h2>Welcome "+usr+"</h2><hr>");
[Link]("<h2>Select the book you would like to purchase<h2><hr>");
[Link]("<form action='LoginSuccess'>");
[Link]("<input type=radio name='book' checked value='Let us C'/>Let us C<br>");

[Link]("<input type=radio name='book' value='Exploring Python'/>Exploring


Python<br>");
[Link]("<input type=radio name='book' value='Mastering C'/>Mastering C<br>");
[Link]("<input type=submit value='purchase'><hr>");

}
}
if(flag==true)
{
[Link]("<h4>Invalid user name or password or card number,please try again by
clicking following link</h4>");
[Link]("<a href='[Link]'>"+"[Link]");
}
}
}
[Link]
package shopping;
import [Link].*;
import [Link].*;
import [Link].*;
public class LoginSuccess extends HttpServlet
{
protected void doGet(HttpServletRequest req,HttpServletResponse res) throws
ServletException,IOException
{
Cookie[] mycookie=[Link]();
[Link]("text/html");
PrintWriter out=[Link]();
String book=[Link]("book");
[Link]("<h2>welcome "+mycookie[0].getValue()+"</h2><hr>");
[Link]("<h3>Thank you for purchasing book:"+book+"</h3><hr>");
[Link]("<h3>Rs.250 debited from credit card: "+mycookie[1].getValue());
[Link]();
}
}
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link] [Link]
app_3_1.xsd">
<servlet>
<init-param>
<param-name>usernames</param-name>
<param-value> indhu,abc,xyz</param-value>
</init-param>
<init-param>
<param-name>passwords</param-name>
<param-value>indhu,abc,xyz</param-value>
</init-param>
<init-param>
<param-name>cardIDs</param-name>
<param-value>111111,222222,333333</param-value>
</init-param>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LoginSuccess</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginSuccess</servlet-name>
<url-pattern>/LoginSuccess</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
RESULT:
Ex. No: CONVERSION OF STATIC WEBPAGES INTO DYNAMIC USING JSP
Date :

PROGRAM :

[Link]:
<html>
<body bgcolor=”pink”>
<br><br><br><br><br><br>
<h1 align=”center”>>U>ONLINE BOOK STORAGE</u></h1><br><br><br>
<h2 align=”center”><PRE>
<b> Welcome to online book storage.
Press LOGIN if you are having id
Otherwise press REGISTRATION
</b></PRE></h2>
<br><br><pre>
<div align=”center”><a href=”/tr/[Link]”>LOGIN</a>
href=”/tr/[Link]”>REGISTRATION</a></div></pre>
</body></html>

[Link]:
<html>
<body bgcolor=”pink”><br><br><br>
<form name="myform" method="post" action=/tr1/[Link]">
<div align="center"><pre>
LOGIN ID : <input type="passwors" name="pwd"></pre><br><br>
PASSWORD : <input type="password" name="pwd"></pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
type="reset"
value="clear">
</form>
</body>
</html>
[Link]:
<html>
<body bgcolor="pink"><br><br>
<form name="myform" method="post" action="/tr1/[Link]">
<div align="center"><pre>
NAME :<input type="text" name="name"><br>
ADDRESS :<input type="text" name="addr"><br>
CONTACT NUMBER : <input type="text" name="phno"><br>
LOGIN ID : <input type="text" name="id"><br>
PASSWORD : <input type="password" name="pwd"></pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
onClick="validate()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"
value="clear">
</form>
</body>
</html>

[Link]:
<html>
<body bgcolor="pink"><br><br>
<form name="myform" method="post" action="/tr1/[Link]">
<div align="center"><pre>
LOGIN ID : <input type="text" name="id"><br>
</pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
onClick="validate()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"
value="clear">
</form>
</body>
</html>

[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<form method="post" action="/tr1/[Link]">
<div align="center"><pre>
BOOK TITLE : <input type="text" name="title"><br>
</pre><br><br>
</div>
<br><br>
<div align="center">
<inputtype="submit"value="ok"
name=”button1”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<inputtype="reset"value="clear"
name=”button2”>
</form>
</body>
</html>
[Link]:
<html>
<body bgcolor="pink"><br><br><br>
<form method="post" action="/tr1/[Link]">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>
PASSWORD : <input type="password" name="pwd"><br>
TITLE :<input type="text" name="title"><br>
NO. OF BOOKS : <input type="text" name="no"><br>
DATE : <input type="text" name="date"><br>
CREDIT CARD NUMBER : <input type="password" name="cno"><br></pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" name=”button1”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
type="reset"
value="clear" name=”button2”>
</form>
</body>
</html>

[Link]:
%@page import=”[Link].*”%
%@page import=”[Link].*”%
<%
[Link](“<html><body bgcolor=\”pink\”>”);
String id=[Link](“id”);
String pwd=[Link](“pwd”);
Driver d=new [Link]();
[Link](d);
Connection
con=[Link](“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=[Link]();
String sqlstmt=”select id,password from login where id=”+id+” and password=”+pwd+””;
ResultSet rs=[Link](sqlstmt);
int flag=0;
while([Link]())
{
flag=1;
}
if(flag==0)
{
[Link](“SORRY INVALID ID TRY AGAIN ID<br><br>”);
[Link](“ <a href=\”/tr1/[Link]\”>press LOGIN to RETRY</a>”);
}
else
{
[Link](“VALID LOGIN ID<br><br>”);
[Link](“<h3><ul>”);
[Link](“<li><ahref=\”[Link]\”><fontcolor=\”black\”>USER
PROFILE</font></a></li><br><br>”);
[Link](“<li><ahref=\”[Link]\”><fontcolor=\”black\”>BOOKS
CATALOG</font></a></li><br><br>”);
[Link](“<li><ahref=\”[Link]\”><fontcolor=\”black\”>ORDER
CONFIRMATION</font></a></li><br><br>”);
[Link](“</ul>”);
}
[Link](“<body></html>”);
%>

[Link]:
%@page import=”[Link].*”%
%@page import=”[Link].*”%
<%
[Link](“<html><body bgcolor=\”pink\”>”);
String name=[Link](“name”);
String addr=[Link](“addr”);
String phno=[Link](“phno”);
String id=[Link](“id”);
String pwd=[Link](“pwd”);
int no=[Link](phno);
Driver d=new [Link]();
[Link](d);
Connection con=
[Link] (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=[Link]();
String sqlstmt=”select id from login”;
ResultSet rs=[Link](sqlstmt);
int flag=0;
while([Link]())
{
if([Link]([Link](1)))
{
flag=1;
}
}
if(flag==1)
{
[Link](“SORRY LOGIN ID ALREADY EXISTS TRY AGAIN WITH NEW ID <br><br>”);
[Link](“<a href=\”/tr1/[Link]\”>press REGISTER to RETRY</a>”);
}
else
{
Statement stmt1=[Link] ();
[Link] (“insert into login values (“+name+”,”+addr+”,”+no+”,”+id+”,”+pwd+”)”);
[Link] (“YOU DETAILS ARE ENTERED <br><br>”);
[Link] (“<a href =\”/tr1/[Link]\”>press LOGIN to login</a>”);
}
[Link] (“</body></html>”);
%>

[Link]:
<%@page import=”[Link].*”%>
<%@page import=”[Link].*”%>
<%
[Link] (“<html><body bgcolor=\”pink\”>”);
String id=[Link](“id”);
Driver d=new [Link]();
[Link](d);
Connection con=
[Link] (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=[Link] ();
String sqlstmt=”select * from login where id=”+id+””;
ResultSet rs=[Link] (sqlstmt);
int flag=0;
while([Link]())
{
[Link] (“<div align=\”center\”>”);
[Link]
(“NAME :”+[Link](1)+”<br>”);
[Link] (“ADDRESS :”+[Link](2)+”<br>”);
[Link] (“PHONE NO :”+[Link](3)+”<br>”);
[Link] (“</div>”);
flag=1;
}
if(flag==0)
{
[Link](“SORRY INVALID ID TRY AGAIN ID <br><br>”);
[Link](“<a href=\”/tr1/[Link]\”>press HERE to RETRY </a>”);
}
[Link] (“</body></html>”);
%>

[Link]:
<%@page import=”[Link].*”%>
<%@page import=”[Link].*”%>
<%
[Link] (“<html><body bgcolor=\”pink\”>”);
String title=[Link] (“title”);
Driver d=new [Link]
(); [Link] (d);
Connection con=
[Link] (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=[Link] ();
String sqlstmt=”select * from book where title=”+title+””;
ResultSet rs=[Link] (sqlstmt);
int flag=0;
while([Link]())
{
[Link] (“<div align=\”center\”>”);
[Link] (“TITLE :”+[Link](1)+”<br>”);
[Link] (“AUTHOR :”+[Link](2)+”<br>”);
[Link] (“VERSION:”+[Link](3)+”<br>”);
[Link] (“PUBLISHER :” +[Link](4)+”<br>”);
[Link] (“COST :” +[Link](5)+”<br>”);
[Link] (“</div>”);
flag=1;
}
if(flag==0)
{
[Link](“SORRY INVALID ID TRY AGAIN ID <br><br>”);
[Link](“<a href=\”/tr1/[Link]\”>press HERE to RETRY </a>”);
}
[Link] (“</body></html>”);
%>

[Link]:
<%@page import=”[Link].*”%>
<%@page import=”[Link].*”%>
<%
[Link] (“<html><body bgcolor=\”pink\”>”);
String id=[Link] (“id”);
String pwd=[Link] (“pwd”);
String title=[Link] (“title”);
String count1=[Link] (“no”);
String date=[Link] (“date”);
String cno=[Link] (“cno”);
int count=[Link](count1);
Driver d=new [Link] ();
[Link] (d);
Connection con=
[Link] (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=[Link] ();
String sqlstmt=”select id, password from login”;
ResultSet rs=[Link] (sqlstmt);
int flag=0,amount,x;
while([Link]())
{
if([Link]([Link](1))&& [Link]([Link](2)))
{
flag=1;
}
}
if(flag==0)
{
[Link](“SORRY INVALID ID TRY AGAIN ID <br><br>”);
[Link](“<a href=\”/tr1/[Link]\”>press HERE to RETRY </a>”);
}
else
{
Statement stmt2=[Link]();
String s=”select cost from book where title=”+title+””;
ResultSet rs1=[Link](s);
int flag1=0;
while([Link]())
{
flag1=1;
x=[Link]([Link](1));
amount=count*x;
[Link](“AMOUNT :”+amount+”<br><br><br><br>”);
Statement stmt1=[Link] ();
[Link] (“insert into details (“+id+”,”+title+”,”+amount+”,”+date+”,”+cno+”)”);
[Link] (“YOU ORDER HAS TAKEN<br>”);
}
if(flag1==0)
{
[Link](“SORRY INVALID BOOK TRY AGAIN <br><br>”);
[Link](“<a href=\”/tr1/[Link]\”>press HERE to RETRY </a>”);
}
}
[Link] (“</body></html>”);%>

OUTPUT:
RESULT:
Ex. No:8 CREATION OF XML DOCUMENT
Date :

PROGRAM :

[Link]:
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>Searching for XML Elements </TITLE>
<SCRIPT>
function readXMLData()
{
var xmlDocumentObject, id , name , addr, phone, email;
xmlDocumentObject=new XMLHttpRequest();
[Link]("GET","[Link]",false);
[Link]();
xmlDocumentObject=[Link];
id = [Link]("userid");
name = [Link]("username");
address = [Link]("address");
phone = [Link]("phone");
email = [Link]("email");
for (i = 0; i < [Link]; i++)
{
output=id[i].[Link];
if (output == [Link]("myText").value)
{[Link] = id[i].[Link] + "<br> " + name[i].[Link]
+"<br> " +address[i].[Link] + "<br> " +
phone[i].[Link]+"<br>"+email[i].[Link];
}}}
</SCRIPT>
</HEAD>
<BODY>
<H1>Search User</H1>
<input type="text" id="myText" value="">
<input type="BUTTON" VALUE="Get User Details" ONCLICK="readXMLData()">
<P>
<DIV ID="displayDIV"> </DIV>
</BODY>
</HTML>
[Link]:
<userlist>
<userid>usr01</userid>
<username>indhu</username>
<address>trichy</address>
<phone>9000000078</phone>
<email>indhu@[Link]</email>
<userid>usr02</userid>
<username>Pooja</username>
<address>chennai</address>
<phone>9111111111</phone>
<email>pooja@[Link]</email>
<userid>usr03</userid>
<username>sadhana</username>
<address>telugana</address>
<phone>9222222222</phone>
<email>sadhana@[Link]</email>
<userid>usr04</userid>
<username>sameera</username>
<address>bangalore</address>
<phone>9555555555</phone>
<email>sameera@[Link]</email>
<userid>usr05</userid>
<username>naveena</username>
<address>Perambalur</address>
<phone>9666666666</phone>
<email>naveena@[Link]</email>
</userlist>

OUTPUT:
RESULT:
[Link]: FORM VALIDATION USING PHP REGULAR EXPRESSION
Date:

AIM:
To validate the form using PHP regular expression.

PROCEDURE:
1. Form is created for class registration with fileds.
2. These fields are validated using PHP code.
3. Form is displayed.

PROGRAM:

[Link]:
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
f (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-
9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
}
if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>PHP Form Validation Example</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="<?php echo $name;?>">
<span class="error">* <?php echo $nameErr;?></span>
<br><br>
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
<span class="error">* <?php echo $emailErr;?></span>
<br><br>
Website: <input type="text" name="website" value="<?php echo $website;?>">
<span class="error"><?php echo $websiteErr;?></span>
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"><?php echo
$comment;?></textarea>
<br><br>
Gender:
<input type="radio" name="gender" <?php if (isset($gender) &&
$gender=="female") echo "checked";?> value="female">Female
<input type="radio" name="gender" <?php if (isset($gender) && $gender=="male")
echo "checked";?> value="male">Male
<input type="radio" name="gender" <?php if (isset($gender) && $gender=="other")
echo "checked";?> value="other">Other
<span class="error">* <?php echo $genderErr;?></span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>
</body>
</html>

OUTPUT:

RESULT:
.
[Link]: STORING A FORM DATA IN PHP
Date:

AIM:
To store a PHP form data into database.

PROCEDURE:
1. Form is created with fileds name, mail id, contact and address.
2. Table is created in mysql.
3. The input data entered into the fields are stored using PHP code.

PROGRAM:

[Link]:
<!DOCTYPE html>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website =$result= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}

if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-
9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";

}
}
if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "iplab";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO register (name, email,website,comments,gender)
VALUES ('$name', '$email', '$website','$comment', '$gender')";
if ($conn->query($sql) === TRUE) {
$result="New Record Inserted Successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Registration Form</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name">
<span class="error">* <?php echo $nameErr;?></span>
<br><br>
E-mail: <input type="text" name="email">
<span class="error">* <?php echo $emailErr;?></span>
<br><br>
Website: <input type="text" name="website">
<span class="error"><?php echo $websiteErr;?></span>
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<span class="error">* <?php echo $genderErr;?></span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo $result;
?>
</body>
</html>
OUTPUT:

RESULT:
[Link]: WEB SERVICE FOR FINDING PEOPLE’S OPINION
Date:

AIM:
To Write a web services for finding what people think by asking 500 people’s opinion for
any consumer product

PROCEDURE:
1. Open the home page.
2. Enter the login ID and type the comments then submit.
3. Retrieve comments with post id
4. Display the comments.

PROGRAM:

[Link]
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery Ajax Comment System - Demo</title>
<link rel="stylesheet" href="css/[Link]">
<script src="[Link]
<script src="js/[Link]"></script>
</head>
<body>
<div class="wrap">
<h1> Maggy Noodles Comment System</h1>
<?php
/
/

r
e
t
r
i
v
e
?>
p
o
s
t

i
n
c
l
u
d
e
(
'
c n
o .
n p
f h
i p
g '
. )
p ;
h
p d
' b
) C
; o
n
i n
n e
c c
l t
u (
d )
e ;

( $query = mysql_query(
' 'SELECT *
f FROM post
u WHERE post_id = 1');
n $row = mysql_fetch_array($query);
c
t <div class="post">
i <h2><?php echo $row['post_title']?></h2>
o <p><?php echo $row['post_body']?></p>
y
<?php (
</div> "
S
// retrive comments with post id E
$comme L
n E
t C
_ T
q *
u FROM comment
e WHE
r RE
y post_i
= d=
m {$row
y ['post_
s id']}
q ORDE
l R BY
_ comm
q ent_id
u DESC
e LIMIT
r 15");
?>
<h2>Comments. </h2>
<div class="comment-block">
<?php while($comment = mysql_fetch_array($comment_query)): ?>
<div class="comment-item">
<div class="comment-avatar">
<img src="<?php echo avatar($comment['mail']) ?>" alt="avatar">
</div>
<div class="comment-post">
<h3><?php echo $comment['name'] ?> <span>said. </span></h3>
<p><?php echo $comment['comment']?></p>
</div>
</div>
<?php endwhile?>
</div>
<h2>Submit new comment</h2>
<!--comment form -->
<form id="form" method="post">
<!-- need to supply post id with hidden fild -->
<input type="hidden" name="postid" value="<?php echo $row['post_id']?>">
<label>
<span>Name *</span>
<input type="text" name="name" id="comment-name" placeholder="Your name here " required>
</label>
<label>
<span>Email *</span>
<input type="email" name="mail" id="comment-mail" placeholder="Your mail here " required>
</label>
<label>
<span>Your comment *</span>
<textarea name="comment" id="comment" cols="30" rows="10" placeholder="Type your
comment here " required></textarea>
</label>
<input type="submit" id="submit" value="Submit Comment">
</form>
</div>
</body>
</html>

Ajax_Comment.php
<?php
if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):
include('[Link]');
include('[Link]');
dbConnect();

if (!empty($_POST['name']) AND !empty($_POST['mail']) AND


!empty($_POST['comment']) AND !empty($_POST['postid'])) {
$name = mysql_real_escape_string($_POST['name']);
$mail = mysql_real_escape_string($_POST['mail']);
$comment = mysql_real_escape_string($_POST['comment']);
$postId = mysql_real_escape_string($_POST['postid']);
mysql_query("
INSERT INTO comment
(name, mail, comment, post_id)
VALUES('{$name}', '{$mail}', '{$comment}', '{$postId}')");
}
?>
<div class="comment-item">
<div class="comment-avatar">
<img src="<?php echo avatar($mail) ?>" alt="avatar">
</div>
<div class="comment-post">
<h3><?php echo $name ?> <span>said. </span></h3>
<p><?php echo $comment?></p>
</div>
</div>

<?php
dbConnect(0);
endif?>

[Link]
<?php
# db configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', 'root');
define('DB_NAME', 'dbname');
?>

[Link]
<?php
/**
* Connect to mysql server
* @param bool
* @use true to connect false to close
*/
function dbConnect($close=true){
if (!$close) {
mysql_close($link);
return true;
}
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to
MySQL DB ') . mysql_error();
if (!mysql_select_db(DB_NAME, $link))
return false;
}
/**
* gravatar Image
* @see [Link]
*/
function avatar($mail, $size = 60){
$url = "[Link]
$url .= md5( strtolower( trim( $mail ) ) );
// $url .= "?d=" . urlencode( $default );
$url .= "&s=" . $size;
return $url;
}
?>

[Link]
/* general styling */
*{
o
t
h
i
n
g
:

a
n
} t
body{ i
a
l
i
a
s
e
} d
.wrap{ ;

f
o
n
t
-
s
m
o
} o
margin: 0; t
padding: 0; h
box-sizing: border-box; i
-webkit-box-sizing: border-box; n
-moz-box-sizing: border-box; g
-webkit-font-smoothing: antialiased; :
-moz-font-smoothing: antialiased;
a
o n
n t
t i
- a
s l
m i
o a
s 0
e 0
d %
; ;
text-rendering: optimizeLegibility; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2)

font: 12px w
Arial,Tahoma,H i
elvetica,FreeSa d
ns,sans-serif; t
text-transform: h
inherit; :
c
o 7
l 2
o 0
r p
: x
;
#
3 m
3 a
3 r
; g
i
b n
a :
c
k 1
g 5
r p
o x
u
n a
d u
: t
o
# ;
e
7 p
e a
d d
e d
e i
; n
g
w :
i
d 1
t 5
h p
: x

1 2
0 :
p
x 5
; p
x
b ;
a
c b
k o
g r
r d
o e
u r
n -
d r
: a
d
w i
h u
i s
t :
e
; 5
border: 2px solid #DBDBDB; p
-webkit-border-radius: 5px; x
- ;
m
o o
z v
- e
b r
o f
r l
d o
e w
r :
-
r h
a i
d d
i d
u e
s n
;

a{ text-decoration: none; color: #333}


h1{
font-family: Georgia, "Times New Roman", Times,
serif; font-size: 2.8em;
text-align: center;
margin: 25px 0;
}
h2{font-size: 1.5em; margin: 8px 0}
h3{
font-size: 1.2em;
margin: 5px 0;
}
h3 span{
r
:
}
.item{ b
o
t
h
;

} m
a
f r
o g
n i
t
n
-
:
w
0
e
;
i
g
p
h
a
t
d
:
d
n i
o n
r g
m :
a
l 1
; 0
p
f x
o ;
n
t o
- v
s e
i r
z f
e l
: o
w
1 :
e
m h
; i
d
d
c e
l n
e ;
a border-top: 1px solid #DBDBDB;
.item:last-child{border-bottom:1px solid #DBDBDB}
.item:hover{background: #f9f9f9}
.post{
padding: 10px 0;
border-bottom: 1px solid #E6E6E6;
}
.comment-block{
margin: 20px 0 20px 20px;
}
.comment-item{
overflow: hidden;
width: 500px;
clear: both;
padding: 10px;
border: 1px solid #E6E6E6;
border-radius: 5px;
margin: 5px;
}
.comment-avatar{
width: 60px;
float: left;
}
.comment-avatar img{
width: 60px;
height: 60px;
border-radius: 5px;
}
.comment-post{
width: 400px;
float: left;
padding: 0 5px 0 10px;
}
#form{
c
l
e
} a
r
:

b
o
t
h
;

m
a
r
g
i
n
:

1
0
p
x
;
5
w 0
i 0
d p
t x
h ;
:

/* form styling */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea {
width:100%;
background: #fff;
border: 1px solid #ddd;
font-size: 13px;
line-height: 20px;
margin: 0;
padding: 7px 10px;
box-shadow: inset 0 1px 2px #eee;
border:1px solid #CCC;
margin:0 0 5px;
border-radius:5px;
}

textarea {
height:100px;
max-width:100%;
}
input[type="submit"] {
cursor:pointer;
width:100%;
border:none;
background:#991D57;
background-image:linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
background-image:-moz-linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
background-image:-webkit-linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
color:#FFF;
margin:0 0 5px;
padding:10px;
border-radius:5px;
}
input[type="submit"]:hover {
background-image:linear-gradient(bottom, #9C215A 0%, #A82767 52%);
background-image:-moz-linear-gradient(bottom, #9C215A 0%, #A82767 52%);
background-image:-webkit-linear-gradient(bottom, #9C215A 0%, #A82767 52%);
-webkit-transition:background 0.3s ease-in-out;
-moz-transition:background 0.3s ease-in-out;
transition:background-color 0.3s ease-in-out;
}
input[type="submit"]:active {
box-shadow:inset 0 1px 3px rgba(0,0,0,0.5);
}
input:focus,
textarea:focus {
outline:0;
border:1px solid #999;
}
label{
d
i
s
p
} l
a
y e
: r
;
b
l
o
c
k
;

m
a
r
g
i
n
:

5
p
x

0
;
f
o
n
t
-
w
e
i
g
h
t
:

9
0
0
;

c
u
r
s
o
r
:

p
o
i
n
t
.alert{
display: none;
p
a
d
d
i
n
g
:
} 8
p
x

3
5
p
x

8
p
x

1
4
p
x
;

m
a
r
g
i
n
:

2
0
p
x

0
;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
c
o
l
o
r
:

#
4 6
6 e
8 9
8 c
4 6
7 ;
; -webkit-border-radius: 4px;
-
b m
a o
c z
k -
g b
r o
o r
u d
n e
d r
- -
c r
o a
l d
o i
r u
: s
:
#
d 4
f p
f x
0 ;
d
8 b
; o
r
b d
o e
r r
d -
e r
r a
- d
c i
o u
l s
o :
r
: 4
p
# x
d ;

[Link]
$(document).ready(function(){
var form = $('form');
var submit = $('#submit');

[Link]('submit', function(e) {
// prevent default action
[Link]();
// send ajax request
$.ajax({
url: 'ajax_comment.php',
type: 'POST',
cache: false,
data: [Link](), //form serizlize data
beforeSend: function(){
// change submit button value text and disabled it
[Link]('Submitting...').attr('disabled', 'disabled');
},
success: function(data){
// Append with fadeIn see [Link]
var item = $(data).hide().fadeIn(800);
$('.comment-block').append(item);

// reset form and button


[Link]('reset');
[Link]('Submit Comment').removeAttr('disabled');
},
error: function(e){
alert(e);
}
});
});
});
OUTPUT:

RESULT:
VIVA QUESTIONS AND ANSWERS

1. What are the three major components of HTML document?


HTML declaration
The head
The body
2. List out some of the HTML tags?
<LI>, <DIR>, <DL>, <DT>, <DD>, <MENU>, <OL>, </UL>
3. What kind of tag is HTML?
Every HTML tag is either a container tag or standalone tag.
4. How to format tags?
HTML provides a host of tags that we can use to change hoe text is displayed on a browser
screen.
5. Define HTML.
It is a simple page description language, which enables document creation for the web.
6. List out the document structure tags.
<HTML>, <HEAD>, <BASE>, <ISINDEX>, <META>, <LINK>, <SCRIPT>, <STYLR>,
<TITLE>, <BDO>, and <BODY>.
7. What is CSS?
CSS stands for Cascading Style Sheets. Styles define how to display HTML elements.
8. List the features of CSS?
● Text handling including fonts, sizing, styles and spacing.
● Printing specific features, downloadable fonts
● Support for vertical running text, multicolumn layout facilities.
9. What are the three main parts of CSS syntax?
The CSS syntax is made up of three parts: a selector, a property and a value.
10. Selector {property: value}
● The selector is normally the HTML element/tag we wish to define.
● The property is the attribute we wish to change and each property can take a value.
● The property and value are sepaerated by a colon and surrounded by curly braces.
11. How to insert a style sheet?
When a browser reads a style sheet, it will format the document according to it. There
are three ways of inserting a style sheet:
External Style Sheet
Internal Style Sheet
Inline styles
Multiple style sheets
12. List out the basic Internet Protocols.
TCP/IP, POP3, MIME, IMAP
13. What are Web Servers?
A Web Server is software that accepts HTTP requests from web clients and returns an
appropriate resource in the HTTP response.
14. Define Web Clients.
A Web Client is software that accesses a web server by sending an HTTP request
message and processing the resulting HTTP response.
15. How multi-tier architecture is differed from MVC architecture.
In multi tier architecture client tier never communicates directly with the data tier. All
communications must pass through business tier. So it is called linear architecture. Where as
in MVC, the view sends updates to controller, then controller updates model. So it is a
triangular architecture.
16. What is Session ID?
A session ID is a unique identification string usually a long, random and alpha-numeric
string, that is transmitted between the client and the server. Session IDs are usually stored in
the cookies, URLs (in case url rewriting) and hidden fields of Web pages.
17. What are the common mechanisms used for session tracking?
• Cookies • SSLsessions • URL- rewriting
18. Define protocol.
A protocol is a formal set of rules that must be followed in order to communicate.
19. What is the role of server?
• Manages application tasks
• Handles storage
• Handles security
• Provides scalability
• Handles accounting and distribution
20. Define internet.
Network is an interconnection of systems to share data and information. Internet is network
of network or collection of heterogeneous networks.
21. Define XML.
XML is a meta-markup language that provides a format for describing structured data. This
facilitates more structured declarations of content and more meaningful search result across
multiple platforms.
22. Define DTD.
A DTD is a set of rules that specifies how to use XML markup. It contains
specifications for each element, including what the element's attributes are, what
values the attributes can take on and what elements can be contained in others.
23. What are the XML rules for distinguishing between the content of a document and the
Xml markup element?
● The start of XML markup elements is identified by either the less than symbol (), the
apostrophe or single quote (‘) and the double quotation marks (“) are used by XML
for markup.
● To use these special characters as content within your document, you must use the
corresponding general XML entity.
24. List some examples of web services.
SMS: [Link]
Whois: [Link]
op=GetWhoIS
25. List out some web service technologies?
● XML∙ SOAP∙ WSDL
26. What is SOAP?
SOAP - Simple Object Access Protocol - protocol specification for exchanging structured
information in the implementation of Web Services in computer networks. - relies on
Extensible Markup Language (XML) for its message format, and usually relies on other
Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) and Simple
Mail Transfer Protocol (SMTP), for message negotiation and transmission.

You might also like