You are on page 1of 70

GREATER NOIDA INSTITUTE OF TECHNOLOGY

(COLLEGE CODE:-132)

SUBJECT CODE:->KCS652

B.TECH 3RD YEAR(COMPUTER SCIENCE DEPARTMENT)

SECTION-E
BATCH:-2018-2022
WEB TECHNOLOGY LAB FILE

SUNMITTED BY- SUBMITTED TO


RUCHIKA JAISWAL MRS.DIVYA MISHRA
ROLL NO.-1813210130
INDEX

S.NO EXPERIMENT DATE REMARK


Wap to Resume using html
1.

2 Write an HTML program to design


an entry form of student detail .

Wap to program Website using html

3.
Wap to program simple calculator
4 using Applet

Wap to program Time Table


5 using html
wap to for chat server using socket
programming
6
Write a program in XML for
creation of DTD using CSS
7
wap to hut using java applet
8
Install a database (Mysql or
Oracle). Create a table which
9 should contain at least the following
fields: name, password, email-id,
phone number (these should hold
the data from the registration
form). Practice 'JDBC'
connectivity.
Validate the Registration, user
login, user profile and payment by
10. credit card pages using JavaScript
WAP TO RESUME USING HTML.

<html>
<head><title><h2>RESUME</h2></title></head>
<body>
<table border="1" align="center" width="60%">
<tr>
<th><h2> RESUME</h2></th></tr>
<tr>
<th align="left"><h3>Ruchika Jaiswal</h3>
<br>Mobile No:-9773671300</br><br>
EMAIL ID:-ruchikajaiswal2000@gmail</br>
<h2>Objective</h2>
<object>To secure a challenging position in a reputable organization to expand my learnings, knowledge, and
skills.</object>
<h2>Qualification</h2>
<table border="1"><tr><th>Examination</th><th>percentage</th><th>Board university</th></tr>
<tr><td> 10th</td><td>76%</td><td>CBSE</td></tr>
<tr><td> 12th</td><td>70%</td><td>CBSE</td></tr>
<tr><td> B.TECH</td><td>Pursuing</td><td>AKTU</td></tr>
</table>
<h2>PERSONAL CERTIFICATE</h2>
<ul><li>Udemy Instructor</li></ul>
<ul><li>JAVA(certificated by Coursera)</li></ul>
<ul><li>NCC certificate(Grade B)</li></ul>
<h2>Personal Details</h2>
<ul><li>Father Name:-Mr.Ravindra Prasad</li></ul>
<ul><li>Religion:-Hindu</li></ul>
<ul><li>DOB:-23 june 2001</li></ul>
<ul><li>Maritial Status:-Unmarried</li></ul>
</html>

->OUTPUT
RESUME

Rurhika Jaiswal

Mobile No:—9773671300

EMAIL ID:—ruchikajaiswal2000@gmail

Objective
To secure a challenging position in a reputable organization to expand my learnings, knowledge, and skills.

Qualification
Eaamination||percentage||Board universitv|
l0th J76% JCBSE
12th J70% JCBSE
B.TECH ||Rirsuing ||ARTL

PERSONAL CERTIFICATE
• Udemy Instructor

• JAVA(certificated by Coursera)

• NCC certificate(Grade B)

Personal Details
• Father Name:-Mr.Ravindra Prasad

• Religion:-Hindu

• DOB:-23 june 2001

• Maritial Status:-Unmarried
Write an HTML program to design an entry form of student detail .

<Html>
<head>
<title>
Registration Page
</title>
</head>
<body bgcolor="Lightskyblue">
<br>
<br>
<form>
<label> Firstname </label>
<input type="text" name="firstname" size="15"/> <br> <br>
<label> Middlename: </label>
<input type="text" name="middlename" size="15"/> <br> <br>
<label> Lastname: </label>
<input type="text" name="lastname" size="15"/> <br> <br>
<label>
Course :
</label>
<select>
<option value="Course">Course</option>
<option value="BCA">BCA</option>
<option value="BBA">BBA</option>
<option value="B.Tech">B.Tech</option>
<option value="MBA">MBA</option>
<option value="MCA">MCA</option>
<option value="M.Tech">M.Tech</option>
</select>
<br>
<br>
<label>
Gender :
</label><br>
<input type="radio" name="male"/> Male <br>
<input type="radio" name="female"/> Female <br>
<input type="radio" name="other"/> Other
<br>
<br>
<label>
Phone :
</label>

<input type="text" name="country code" value="+91" size="2"/>


<input type="text" name="phone" size="10"/> <br> <br>
Address
<br>
<textarea cols="80" rows="5" value="address">
</textarea>
<br> <br>
Email:
<input type="email" id="email" name="email"/> <br>

<br> <br>
Password:
<input type="Password" id="pass" name="pass"> <br>
<br> <br>
Re-type password:
<input type="Password" id="repass" name="repass"> <br> <br>
<input type="button" value="Submit"/>
</form>
</body>
</html>

OUTPUT
/i/ File C:/Users/Ruchika/Desktop/registration.html

Firstname

Middlename:

Lastname:

Course :

uCse

Gender :
O Male
O Female
O Other

Pbone : 91a

Address

Email:

Password:

Re-type password:

buSm t
Write a program Webpage using HTML
<!DOCTYPE html>
<html>
<head><title>How to make a website using notepad</title><style>
img{
position:relative; }
h1{ color:red;position;absolute;left:150px;
top:100px;
}*{
margin:0;
padding:0;
}
header{ heig
ht:60px;
background:#262626;
padding:0 50px;
}
.
logo{ widt
h:30%;
float:left;
color:#fff;
font-weight:bold;
text-transform:uppercase;
line-height:60px;
font-size:35px;
font-family:sans-serif;
}
nav{ width:
68%;
float:right;
}
nav ul{
list-style:none;float:right;
}
nav ul li{
display: inline-block;
}
nav ul li a{
text-decoration: none;
color:#fff;
font-family:sans-serif;
font-weight:bold;
margin:0 10px;
line-height:60px;
text-transform:uppercase;
}
.
banner{ heig
ht:100%;
}
.banner img{
width:100%;
height:90vh;
}
.
content{ pad
ding:5%;
}
.content
p{ font-
size:18px; line-
height:1.7;
font-family:sans-serif;
margin-bottom:25px;
}

footer{ background
:#000; color:#fff;
padding:15px 50px;
text-align:center;
} @media (max-width: 600px){ header {
width: 100%;
height: 100%;

padding: 0;
text-align: center;
}
.logo {
width: 100%;
float: none;
}
nav {
width: 100%;
float: none;
}
nav ul li
{ display:
block;
}
nav ul
{ float:
none;
}
}
</style>
</head>
<body>
<header>
<div class="logo">
Logo
</div>
<nav>
<ul>
<li>
<a href="#">Home</a>
</li>
<li><a href="#">About</a></li>
<li>

<a href="#">Portfolio</a>
</li>
<li>

<a href="#">Services</a>
</li>
<li>

<a href="#">Contact</a>
</li></ul</nav>
</header>
<div class="banner"><img alt="https://www.google.com/url?sa=i&url=https%3A%2F%2Fbcct.ngo%2Fassets
%2Ftemplateimages%2F%3FMA&
psig=AOvVaw20FKRprKjpVa1DbScJUQGs&ust=1619779798807000&source=images&cd=vfe&ved=0CAIQjRxqF
woTCIi_5pWko_ACFQAAAAAdAAAAABAE" src="111111.jpg"></div><div class="content">
<p>A non-governmental organization (NGO) is a non-profit group that functions independently of any
government. NGOs, sometimes called civil societies, are organized on community, national and international levels to
serve a social or political goal such as humanitarian causes or the environment. <br> <b><h1>KEY
TAKEAWAYS</h1> </b></br>
<h2> NGOs, or non-governmental organizations, play a major role in international development, aid and
philanthropy.
NGOs are non-profit by definition, but may run budgets of millions or up to billions of dollars each year.
As such, NGOs rely on a variety of funding sources from private donations and membership dues to
government contribution.</br></p>
<footer>
<p>All Right Reserved By Your Website</p> </footer>
</body>
</html>

OUTPUT
File I C:/lJsers/Ruchika/Desktop/website.html

LOGO HOMEABOUTPORTFOLIOSERVICESCONTACT

://www.google.com/url?
irl=https%3A%2F%2Fbcct.ngo%2Fassets%2Ftemplateimages%2F%3FMA&psi AOvVaw20FKRprKjpVa1DbScJUQGs&usm1619779798807000&sotircwimages&cdmfe&ved=0CAIQjRxqFwoTCIi_5pWko_ACFQ

A non-governmental organization (NGO) is a non-profit group that functions independently of any government. NGOs, sometimes called civil societies, are organized on
community, national and international levels to serve a social or political goal such as humanitarian causes or the environment.

KEY TAKEAWAYS
NGOs, or non-governmental organizations, play a major role in international development, aid and philanthropy. NGOs are non-profit
by definition, but may run budgets of millions or up to billions of dollars each year. As such, NGOs rely on a variety of funding sources
from private donations and membership dues to government contribution.

All Right Reserved By Your Website


Write a program Simple Calculator using JAVA APPLET

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Cal extends Applet implements ActionListener
{
Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16;
String s1="",s2;
Frame f;Panel p2;
TextField t;int n1,n2;
public void init()
{
setLayout(new BorderLayout());
t=new TextField();
p2=new Panel();
p2.setLayout(new GridLayout(4,4));
b1=new Button("1"); b1.addActionListener(this);
b2=new Button("2"); b2.addActionListener(this);
b3=new Button("3"); b3.addActionListener(this);
b4=new Button("+"); b4.addActionListener(this);
b5=new Button("4"); b5.addActionListener(this);
b6=new Button("5"); b6.addActionListener(this);
b7=new Button("6"); b7.addActionListener(this);
b8=new Button("-"); b8.addActionListener(this);
b9=new Button("7"); b9.addActionListener(this);
b10=new Button("8"); b10.addActionListener(this);
b11=new Button("9"); b11.addActionListener(this);
b12=new Button("*"); b12.addActionListener(this);
b13=new Button("c"); b13.addActionListener(this);
b14=new Button("0"); b14.addActionListener(this);
b15=new Button("/"); b15.addActionListener(this);
b16=new Button("="); b16.addActionListener(this);
add(t,"North");
p2.add(b1);p2.add(b2);p2.add(b3);p2.add(b4);
p2.add(b5);p2.add(b6);p2.add(b7);p2.add(b8);
p2.add(b9);p2.add(b10);p2.add(b11);p2.add(b12);
p2.add(b13);p2.add(b14);p2.add(b15);p2.add(b16);
add(p2);
}
public void actionPerformed(ActionEvent e1)
{
String str=e1.getActionCommand(); if(str.equals("+")||
str.equals("-")||str.equals("*")||str.equals("/"))
{String str1=t.getText();
s2=str;
n1=Integer.parseInt(str1);
s1="";
}
else if(str.equals("="))
{
String str2=t.getText();
n2=Integer.parseInt(str2);
int sum=0;
if(s2=="+")
sum=n1+n2;
else if(s2=="-")
sum=n1-n2;
else if(s2=="*")
sum=n1*n2;
else if(s2=="/")
sum=n1/n2;
String str1=String.valueOf(sum);
t.setText(""+str1);
s1="";
}
else if(str.equals("c"))
{
t.setText("");
}
else
{
s1+=str;
t.setText(""+s1);
}
}
}
/*<applet code="Cal" height=300 width=300>
</applet>*/

OUTPUT
WAP TO TIME TABLE USING HTML

<html>
<head></head>
<TITLE>
TIME TABLE
</TITLE>
<BODY>
<table align="CENTER" BORDER = 1 CELLPADDING = 10 style="text-align:center" <tr>
<TD><B>DAYS</B></TD>
<td>I</td>
<td><B>II</B></td>
<td><b>III</b></td>
<td><b>IV</b></td>
<td><b>V</b></td>
<td><B>VI</B></td>
<TD><B>VII</B></TD>
<TD><b>VIII</TD>
</tr><tr> <td><B>MONDAY</B></td>
<td>KOE 064</td>
<td>KCS 601</td>
<td>KCS 603</td>
<td>KCS 602</td>
<td>KCS 061</td>
<td>KNC 602</td>
<td COLSPAN = 2>SE LAB</td> </tr> <tr>
<td><B>TUESDAY</B></td>
<TD>KCS 602</TD>
<td>KCS 061</td>
<TD>KCS 601</TD>
<td>KCS 602</td>
<td COLSPAN = 2 >CN LAB</td>
<td>KCS 061</td>
<td>KCS 603</td> </tr><tr> <td><b>WEDNESDAY</b></td>
<td>KOE 064</td>
<td COLSPAN = 2 bgcolor="YELLOW">QUANT</td>
<td>KCS 061</td>
<td>KCS 603</td>
<td>KCS 602</td>
<td>KNC 602</td>
<TD>KCS 601</TD>
</tr> <tr>
<td><B>THURSDAY</B></td>
<td>KCS 603</td>
<td>KNC 602</td>
<td>KOE 064</td>
<td>KCS 602</td>
<td>KOE 064</td>
<TD>KCS 601</TD>
<td COLSPAN = 2 >WEBTECH LAB</td>
</tr> <tr>
<TD><B>FRIDAY</B></TD>
<TD>KCS 601</TD>
<td COLSPAN = 2 style="text-align:center" bgcolor="YELLOW">PDP</td>
<td>KCS 603</td>
<td>KCS 061</td>
<td>KCS 603</td>
<td>KOE 064</td>
<td>KCS 602</td> </tr>
<caption>TIME TABLE 2021 </caption>
</table>
</BODY>
</html>

OUTPUT
TILIE TABLE 2021

DAYS I II III IV V

MONDAY KOE 064 KCS 601 KC.S 603 KC.S 602 KC.S 061 KNC 602 SE LAB

TLTSDAY KC.S 602 KCS 061 KC.S 601 KC.S 602 CN LAB KCS 061 KC.S 603

WEDNESDAY KOE 064 QUANT KC.S 061 KC.S 603 KCS 602 KNC 602 KC.S 601

THURSDAY KC.S 603 KNC 602 KOE 064 KC.S 602 KOE 064 KCS 601 UTBTEC.H LAB

FRIDAY KC.S 601 PDP KC.S 603 KC.S 061 KCS 603 KOE 064 KC.S 602
WAP TO FOR CHAT SERVER USING SOCKET PROGRAMMING

FILE:Server.java

import java.io.*;

import java.net.*;

class server

public static void main(String args[])throws IOException


{

ServerSocket ss=new ServerSocket(66);

Socket s=ss.accept();

DataInputStream dis=new DataInputStream(s.getInputStream());

String str=(String)dis.readUTF();

System.out.println(str);

ss.close();

}
}

FILE:Client.java

import java.io.*;

import java.net.*;

class client
{

public static void main(String args[])throws Exception


{

Socket s=new Socket("localhost",66);

DataOutputStream dout=new DataOutputStream(s.getOutputStream());


dout.writeUTF("Hi server! how r you?");

dout.flush(); // flush the buffered output stream

dout.close();

s.close();

}
}

OUTPUT:
Write a program in XML for creation of DTD using CSS

Creating book.XML

<?xml version="1.0" encoding="UTF-8"?>


<?xml-stylesheet type="text/css" href="creating rule.css"?>
<books>
<heading>Welcome To GNIOT </heading>
<book>
<title>Title -: Web Technology</title>
<author>Teacher -: Divya Mishra</author>
<publisher>Publisher -: Wiley</publisher>
<edition>Edition -: 3</edition>
<price> Price -: 300</price>
</book>
<book>
<title>Title -: Internet world-wide-web</title>
<author>Author -: Ditel</author>
<publisher>Publisher -: Pearson</publisher>
<edition>Edition -: 3</edition>
<price>Price -: 400</price>
</book>
<book>
<title>Title -: Computer Networks</title>
<author>Author -: Foruouzan</author>
<publisher>Publisher -: Mc Graw Hill</publisher>
<edition>Edition -: 5</edition>
<price>Price -: 700</price>
</book>
<book>
<title>Title -: DBMS Concepts</title>
<author>Author -: Navath</author>
<publisher>Publisher -: Oxford</publisher>
<edition>Edition -: 5</edition>
<price>Price -: 600</price>
</book>
<book>
<title>Title -: Linux Programming</title>
<author>Author -: Subhitab Das</author>
<publisher>Publisher -: Oxford</publisher>
<edition>Edition -: 8</edition>
<price>Price -: 300</price>
</book>
</books>

Creating Rule.CSS
books {
color: white;
background-color : gray;
width: 100%;
}
heading {
color: green;
font-size : 40px;
background-color : powderblue;
}
heading, title, author, publisher, edition, price {
display : block;
}
title {
font-size : 25px;
font-weight : bold;
}

OUTPUT
WAP TO HUT USING JAVA APPLET

import java.awt.*;
import java.applet.*;

public class Main extends Applet


{
public void init()
{
f1=new Font("Arial",Font.BOLD,30);
setBackground(Color.cyan);
}
public void paint(Graphics gp)
{ g.setFont(f1);
g.drawString("My House",365,60);
g.drawRect(250,250,500,200);
g.drawRect(250,250,200,200);
g.drawRect(300,300,100,150);
g.drawRect(550,320,100,60);
g.drawLine(250,250,355,100);
g.drawLine(355,100,450,250);
g.drawLine(355,100,650,100);
g.drawLine(650,100,750,250);
}
}

OUTPUT
PROGRAM -9

Install a database (Mysql or Oracle). Create a table which should contain at least the following fields:
name, password, email-id, phone number (these should hold the data from the registration form).

Practice 'JDBC' connectivity.

Write a java program/servlet/JSP to connect to that database and extract data from the tables and
display them. Experiment with various SQL queries. Insert the details of the users who register with
the web site, whenever a new user clicks the submit button in the registration page .

Main.html:
<html>
<body>
<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="login.html">LOGIN</a> <a href="reg.html">
REGISTRATION</a></div></pre>
</body>
</html>
login.html:

<html>
<body><br /><br /><br />
<form name="myform" method="post" action="login">
<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"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" />
</div>
</form>
</body>
</html>

Profile.html
<html>
<body><br /><br /><br />
<form name="myform" method="post" action="profile">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id" /><br />
</pre><br /><br />
</div>
<br /><br />
<div align="center">
<input type="submit" value="ok" onclick="validate()" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" />
</div>
</form>
</body>
</html>

Userinfo.html
<html>
<head>
<title>User Info Entry Form</title>
</head>
<body bgcolor="white">
<form action="userinfo1.jsp" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="userName" >
</td>
</tr>
<tr>
<td>Sex:</td>
<td><input type="text" name="sex" >
</td>
<td>(Male or female)</td>
</tr>
<tr>
<td colspan=2><input type="submit"></td>
</tr>
</table>
</form>
</body>
</html>

Reg.html
<html>
<body><br /><br />
<form name="myform" method="post" action="reg">
<table align="center" >
<tr>
<td>NAME</td>
<td>:<input type="text" name="name" /></td>
</tr>
<tr>
<td>ADDRESS</td>
<td>:<input type="text" name="addr" /></td>
</tr>
<tr>
<td>CONTACT NUMBER</td>
<td>:<input type="text" name="phno" /></td>
</tr>
<tr>
<td>LOGINID</td>
<td>:<input type="text" name="id" /></td>
</tr>
<tr>
<td>PASSWORD</td>
<td>:<input type="password" name="pwd" /></td>
</tr>
</table>
<br /><br />
<div align="center">
<input type="submit" value="ok" onclick="validate()" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" />
</div>
</form>
</body>
</html>

login.java
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException
{
PrintWriter pw=resp.getWriter();
pw.println("<html><body>");
String id=req.getParameter("id");
String pwd=req.getParameter("pwd");
String s1="",s2="";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:XE","system",
"tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{
s1=rs.getString(4);
s2=rs.getString(5);
}
if(id.equals(s1)&&pwd.equals(s2))
{
flag=1;
}
if(flag==0)
{
pw.println("<br><br>SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\"login.html\">press LOGIN to RETRY</a>");
}e
lse
{
pw.println("<br><br>WELCOME TO "+id.toUpperCase()+"<br><br>");
pw.println("<h3><ul>");
pw.println("<li><a href=\"profile.html\"><fontcolor=\"black\">
USER PROFILE</font></a></li><br><br>");
pw.println("<li><a href=\"catalog.html\"><fontcolor=\"black\">BOOKS
CATALOG</font></a></li><br><br>");
pw.println("<li><a href=\"order.html\"> <fontcolor=\"black\">ORDER
CONFIRMATION</font></a></li></ul><br><br>");
}
pw.println("</body></html>");
}c
atch(Exception e)
{
resp.sendError(500,e.toString());
}
}
}

reg.java:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class reg extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,IOException
{
PrintWriter pw=resp.getWriter();
resp.setContentType("text/html");
pw.println("<html><body>");
String name=req.getParameter("name");
String addr=req.getParameter("addr");
String phno=req.getParameter("phno");
String id1=req.getParameter("id");
String pwd1=req.getParameter("pwd");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1522 :XE","system","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from login";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{
if(id1.equals(rs.getString(4))&&pwd1.equals(rs.getString(5)))
{
flag=1;
}
}i
f(flag==1)
{
pw.println("<br><br>SORRY INVALID ID ALREADY EXITS
TRY AGAIN WITH NEW ID<br><br>");
pw.println("<a href=\"reg.html\">press REGISTER to RETRY</a>");
}e
lse
{
Statement stmt1=con.createStatement();
stmt1.executeUpdate("insert into login values
('"+name+"','"+addr+"','"+phno+"','"+id1+"','"+pwd1+"')");

pw.println("<br><br>YOUR DETAILS ARE ENTERED<br><br>");


pw.println("<a href=\"login.html\">press LOGIN to login</a>");
}
pw.println("</body></html>");
}c
atch(Exception e)
{
resp.sendError(500,e.toString());
}
}
}

Catalog.java:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class catalog extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException
{
PrintWriter pw=resp.getWriter();
pw.println("<html><body>");
String title=req.getParameter("title");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:XE","system","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from book where title=\'"+title+"\'";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
while(rs.next())
{
pw.println("<div align=\"center\">");
pw.println("TITLE :"+rs.getString(1)+"<br>");
pw.println("AUTHOR :"+rs.getString(2)+"<br>");
pw.println("VERSION :"+rs.getString(3)+"<br>");
pw.println("PUBLISHER :"+rs.getString(4)+"<br>");
pw.println("COST :"+rs.getString(5)+"<br>");
pw.println("</div>");
flag=1;
}i
f(flag==0)
{
pw.println("<br><br>SORRY INVALID TITLE TRY AGAIN <br><br>");

pw.println("<a href=\"catalog.html\">press HERE to RETRY</a>");


}
pw.println("</body></html>");
}c
atch(Exception e)
{
resp.sendError(500,e.toString());
}
}
}

profile.java:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class profile extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException
{
PrintWriter pw=resp.getWriter();
pw.println("<html><body>"); String
id=req.getParameter("id");try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:XE","system","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from login where id='"+id+"'";
ResultSet rs=stmt.executeQuery(sqlstmt);
int flag=0;
pw.println("<br><br><br>");
while(rs.next())
{
pw.println("<div align=\"center\">");
pw.println("NAME :"+rs.getString(1)+"<br>");
pw.println("ADDRESS :"+rs.getString(2)+"<br>");
pw.println("PHONE NO :"+rs.getString(3)+"<br>");
pw.println("</div>");
flag=1;
}if(flag==0)
{
pw.println("<br><br>SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\"profile.html\">press HERE to RETRY</a>");
}
pw.println("</body></html>");
}

catch(Exception e)
{
resp.sendError(500,e.toString());
}
}
}

Order.java:
import java.sql.*; import
java.io.*; import
javax.servlet.*;
import javax.servlet.http.*;
public class order extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException
{
int count;
PrintWriter pw=resp.getWriter();
pw.println("<html><body>");
String id=req.getParameter("id");
String pwd=req.getParameter("pwd");
String title=req.getParameter("title");
String count1=req.getParameter("no");
String date=req.getParameter("date");
String cno=req.getParameter("cno");
Try
{
count=Integer.parseInt(count1);
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:XE","system","tiger");
Statement stmt=con.createStatement();
String sqlstmt="select * from login";
ResultSet rs=stmt.executeQuery(sqlstmt);int
flag=0,amount,x;
while(rs.next())
{
if(id.equals(rs.getString(4))&&pwd.equals(rs.getString(5)))
{
flag=1;
}
}i f(flag==0)
{
pw.println("<br><br>SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href= \" order.html \" >press HERE to RETRY</a>");
}
else
{

Statement stmt2=con.createStatement();
String s="select cost from book where title='"+title+"'";
ResultSet rs1=stmt2.executeQuery(s);
int flag1=0;
while(rs1.next())
{
flag1=1;
x=Integer.parseInt(rs1.getString(1));
amount=count*x;
pw.println("<br><br>AMOUNT:"+amount+"<br><br><br><br>");
Statement stmt1=con.createStatement();
stmt1.executeUpdate("insert into details values('"+id+"','"+title+"','"+amount+"','"+cno+"')");
pw.println("<br>YOUR ORDER has taken<br>");
}i f(flag1==0)
{
pw.println("<br><br><br>SORRY INVALID ID TRY AGAIN ID<br><br>");
pw.println("<a href=\"order.html\">press HERE to RETRY</a>");
}
}
pw.println("</body></html>");
con.close();
}
catch(Exception e)
{
resp.sendError(500,e.toString());
}
}
}
OUTPUT

MAIN.HTML

REGISTRATION:
LOGIN.HTML

LOGIN SERVLET PAGE


PROFILE PAGE

PROFFILE SERVLET PAGE


CATALOG PAGE

CATALOG SERVLET PAGE


ORDER PAGE

ORDER SERVLET PAGE


PROGRAM 10

Validate the Registration, user login, user profile and payment by credit
card pagesusing JavaScript.

PROCEDURE:
Home page:

Main.html:
<html>

<frameset rows="25%,*">

<frame src="top.html" name="top" scrolling ="no" frameborder


="0"> <frameset cols="25%,75%">

<frame src="left.html" name="left" scrolling ="no" frameborder ="0">

<frame src="right.html" name="right" scrolling ="auto" frameborder ="0">

</frameset>

</frameset>

</html>

Top.html:
<html>

<body bgcolor="pink">

<br><br>

<marquee><h1 align=”center”><b><u>ONLINE
BOOK STORAGE</u></b></h1></marquee>
</body>

</html>

<html>
Right.html:
<body>

<br><br><br><br><br>

<h2 align="center">

<b><p> welcome to online book storage. Press login if youare having


id otherwise press registration. </p></b></h2>

</body>

</html>

Left.html:
<html>

<body bgcolor="pink">

<h3>

<ul>

<li><a href="login.html" target="right"><font color="black">


LOGIN</font></a></li><br><br>

<li><a href="profile.html" target="right"><font color="black">USER


PROFILE</font></a></li><br><br>

<li><a href="catalog.html" target="right"><font color="black">BOOKS


CATALOG</font></a></li><br><br>

<li><a href="scart.html" target="right"><font color="black">


SHOPPINGCART</font></a></li><br><br>

<li><a href="payment.html" target="right"><font color="black">


PAYMENT</font></a></li><br><br> <br><br>

</ul>

</body>

</html>
Registration and user Login

Login.html:
<html>

<body bgcolor="pink"><br><br><br>

<script language="javascript">function

validate()

var flag=1;

if(document.myform.id.value==""||

document.myform.pwd.value=="")

alert("LoginId and Password must be filled")flag=0;

if(flag==1)

alert("VALID INPUT");

window.open("catalog.html","right");

else

alert("INVALID INPUT");

//document.myform.focus();

</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()">&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="clear" >

</div>

</form>

</body>

</html>

<script language="javascript">function

validate()

var flag=1;

if(document.myform.id.value==""||

document.myform.pwd.value=="")

alert("LoginId and Password must be filled")flag=0;

if(flag==1)

alert("VALID INPUT");

window.open("catalog.html","right");

else

alert("INVALID INPUT");

//document.myform.focus();

</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()">&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="clear" >

</div>

</form>

</body>

</html>

<script language="javascript">function

validate()

var flag=1;

if(document.myform.id.value==""||

document.myform.pwd.value=="")

alert("LoginId and Password must be filled")flag=0;

if(flag==1)

alert("VALID INPUT");

window.open("catalog.html","right");

else

alert("INVALID INPUT");

//document.myform.focus();
}

</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()">&nbsp;&nbsp;&nbsp;&nbsp;


<input type="reset" value="clear" >

</div>

</form>

</body>

</html>

User profile page

Profile.html:

<html>

<body bgcolor="pink"><br><br>

<script type="text/javascript">function

validate()

var flag=1;

if(document.myform.name.value==""||

document.myform.addr.value==""||

document.myform.phno.value==""||

document.myform.id.value==""||

document.myform.pwd.value=="")

alert("Enter all the details");


flag=0;

var str=document.myform.phno.value;var

x=new RegExp("\\d","g");

if(!(str.match(x)))

if(!(str.length==10))

flag=0;

var str1=document.myform.id.value;

var x1=new RegExp("^[A-Z][a-zA-Z]+$","g");

if(!(str1.match(x1)))

flag=0;

alert("Invalid UserID");

var str1=document.myform.pwd.value;

var x1=new RegExp("^[A-Z][a-zA-Z]+$","g");

if(!(str1.match(x1)))

flag=0;

alert("Invalid password");

if(flag==1)

alert("VALID INPUT");

window.self.location.href="login.html";
alert("INVALID INPUT");

document.myform.focus();

}
}

{
</script>

<form name="myform">

<div align="center"><pre>

NAME :<input type="text" name="name"><br>

ADDRESS :<input type="type" name="addr"><br>

CONTACT NUMBER:<input 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="button" value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;

<input type="reset" value="clear">

</form>

</body>

</html>

Books catalog:

Scart.html:

<html>

<body bgcolor="pink"><br><br><br>

<script language="javascript">

function validate()
{

var flag=1;

if(document.myform.title.value=="")

flag=0;

str=document.myform.title.value;

if(str=="c"||str=="C")

document.myform.t1.value="C";

document.myform.t2.value=444;

else if(str=="jsp"||str=="JSP")

document.myform.t1.value="JSP";

document.myform.t2.value=555;

else

flag=0;

if(flag==1)

alert("VALID INPUT");

else
{

alert("INVALID INPUT");

document.myform.focus();

</script>

<form name="myform" action="payment.html"


target="right"> <div align="center"><pre>

BOOK TITLE :<input type="text"


name="title"><br> </pre><br><br>

Book Title: <input type="text" name="t1" disabled>

Book Cost: <input type="text" name="t2" disabled>

</div>

<br><br>

<div align="center">

<input type="submit" value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="clear">

<input type="submit" value="Purchase">

</form>

</body>

</html>

Shopping cart:

Catalog.html:

<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">function
validate()
{
var flag=1;
if(document.myform.id.value==""||
document.myform.title.value==""||
document.myform.no.value==""||

document.myform.cost.value=="")
{
flag=0;
}
str=document.myform.title.value;
var str1=document.myform.cost.value;
if(!((str=="c"&& str1==444) || (str=="jsp" && str1==555)))
{
flag=0;
}
if(flag==1)
{
alert("VALID INPUT");
}
else
{
alert("INVALID INPUT");
document.myform.focus();
}
}
</script>
<form name="myform" action="scart.html" target="right">
<div align="center"><pre>
LOGIN ID :<input type="text" name="id"><br>TITLE
:<input type="text" name="title"><br>
NO.OF BOOKS :<input type="text" name="no"><br> COST OF
BOOK :<input type="text"name="cost"><br>
</pre><br><br>

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

Payment by credit card

Payment.html:
<html>
<body bgcolor="pink"><br><br><br>
<script language="javascript">function
validate()
{
var flag=1;
if(document.myform.id.value==""|| document.myform.pwd.value==""||
document.myform.amount.value==""|| document.myform.num.value=="")
{
flag=0;
}
var str=document.myform.amount.value;var x=new
RegExp("\\d","g");
if(!(str.match(x)))
{ flag=0;
}
var str1=document.myform.num.value;var
x1=new RegExp("\\d","g"); if(!(str.match(x1)))
{ flag=0;
}i f(flag==1)
{ alert("VALID INPUT");
window.self.location.href="order.html";
} else
{

alert("INVALID INPUT");
document.myform.focus();
}}
</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="button" value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="clear" >
</form>
</body>
</html>

Order Conformation

Order.html:

<html>
<head><title>order conformation</title><M/head>
<body bgcolor="cyan">
<center>
<h1><b>AMAZON</h1>
<pre><strong>
<b>Your order Is Conformed
</strong></pre>
<h2><b>THANK YOU</h2>
</center>
</body>
</html>

OUTPUT:

MAIN.HTML

LOGIN.HTML
ONtLINE BOOK STORAGE

• ERPROMLS LOGZN ED !
PROFILE.HTML

CATALOG.HTML
SCART.HTML

PAYMENT.HTML

You might also like