Web Technology Lab
Web Technology Lab
Web Technology Lab
WEEK 1:
Design the following static web pages required for an online book store web site.
1) HOME PAGE: The static home page must contain three frames.
2) LOGIN PAGE
3) CATOLOGUE PAGE: The catalogue page should contain the details of all the books
available in the web site in a table.
4) REGISTRATION PAGE
Aim: Design the following static web pages required for online book store.
1. Home page:- the static home page must contains three pages
2. Top frame:- logo and college name and links to homepage, login page, registration page
and catalogue page
3. Left frame:- at least four links for navigation which will display the catalogue of
Respective links
4. Right frame:- the pages to links in the left frame must be loaded here initially it Contains
the description of the website.
DESCRIPTION: In this program the entire web paged are created by using basic HTML
tags. Home page is divided into 3 frames by using <frameset> and <frame> tags. A frame is
used to display a web page within a web page.
<frameset>:
The <frameset> tag defines a frameset.
The <frameset> element holds one or more <frame> elements.
Each <frame> element can hold a separate document.
The <frameset> element specifies HOW MANY columns or rows there will be in the
frameset, and HOW MUCH percentage/pixels of space will occupy each of them.
<frame>:
The <frame> tag defines one particular window (frame) within a <frameset>.
Each <frame> in a <frameset> can have different attributes, such as border, scrolling,
the ability to resize, etc.
PROGRAM:
home.html:
<frameset rows="40%,*">
<frame src="top.html" noresize scrolling="NO" name="topframe">
<frameset cols="15%,*">
<frame src="left.html" noresize scrolling="NO" name="leftframe">
<frame src="right.html" noresize name="rightframe" scrolling="auto">
</frameset>
</frameset>
top.html:
<html>
<head>
<title>Top Frame</title>
</head>
<body bgcolor="YellowGreen ">
<img src="images/logo1.png" width="125" height="115" align="left">
left.html:
<html>
<body align="center" bgcolor="bisque"> <br>
<a href="cse.html" target="rightframe"><font size="6">CSE</font></a><br><br>
<a href="ece.html" target="rightframe"><font size="6">ECE</font></a><br><br>
<a href="eee.html" target="rightframe"><font size="6">EEE</font></a><br><br>
<a href="mech.html" target="rightframe"><font size="6">MECH</font></a><br>
</body>
</html>
right.html:
<html>
<body bgcolor="orange">
<center>
<img src="images/Books.jpg" height="170"><br>
<font face="Brush Script MT" size="5" color="blue">
<h1><b>Welcome to the Online Book Store!!!</b></font><br />
<font face="Brush Script MT" size="5" color="red">
<h2><b> "A Huge Collection Of Engineering E-Books"</b></h2></font>
</center>
</body>
</html>
ece.html:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ul>
<li>Digital Circuits</li> <li>Signals and Systems</li> <li>Digital Communication</li>
</ul>
</h2>
</body>
</html>
mech.html:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ol type="I">
<li>Theory of Machines</li>
<li>Automation and Robotics</li>
<li>Engineering Fluid Mechanics</li>
</ol>
</h2>
</body>
</html>
catalogue.html:
<html>
<head>
<title> Catalogue </title>
</head>
<body bgcolor="pink">
<form action="order.html">
<table border="1" width="100%">
<tr>
<td>
<img src="images/wt.jpg" width=100 height=100/>
</td>
<td> Book: Web Technologies <br> Author: Uttam K. Roy <br> Publication:Oxford
University Press</td> <td>531 </td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
<tr>
<td> <img src="images/php.jpg" width=100 height=100/></td>
<td> Book: PHP & MySQL Web Development <br> Author:Luke Welling & Laura
Thompson <br> Publication:PEARSON</td> <td> 898 </td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
</table> </form>
</body> </html>
registration.html:
<html>
<head><title>Registration Form</title></head>
<body bgcolor="#E4F0F8">
<center><font color="blue" size="6" face="arial">Registration Form</font></center><br />
<form action="right.html">
First Name(Minimum 6 characters)<font color="red">* </font>
<input type='text' id='firstname' /><br /><br />
Last Name<font color="red"><font color="red">* </font> </font>
<input type='text' id='lastname' /><br /><br />
EmailAddress<font color="red">* </font>
<input type='text' id='email' /><br />
<font color="red">(one e-mail id only):</font>
<font color="redblue">e.g. smith@hotmail.com</font><br /><br/>
Password(minimum 6 characters)<font color="red">* </font>
<input type='password' id='pass'><br /><br/>
Address<font color="red">* </font>
<textarea rows="2" cols="20" id='addr' /></textarea> <br /> <br/>
Mobile No<font color="red">* </font>
<input type='text' id='mobileno' /><br />
Gender: <input type='radio' name="gender">male
<input type='radio' name="gender">female<br/><br />
<input type='Submit' value='submit' />
<input type='Reset' value='reset' />
</form> </body> </html>
order.html:
<html>
<head><title>order conformation</title></head>
<body bgcolor="cyan">
<center>
<pre><strong>
<b>Your order Is Conformed
</strong></pre>
<h2><b>THANK YOU...Visit Again</h2>
</center>
</body>
</html>
OUTPUT:
EXERCISE:
1. Create your class time table in a webpage.
2. Design the static web pages required for an online shopping cart.
b) factorial.html
<html>
<head>
<title>factorial</title>
<script language='javascript'>
EXERCISE:
1. Write a JavaScript program to find out the Fibonacci Series.
2. Write a JavaScript program to check the given number is palindrome or not.
OUTPUT:
Output:
if($t==$rev)
echo "$rev is a Palindrome";
else
echo "$rev is not a Palindrome";
?>
Output:
EXERCISE:
1. Write a PHP Script to find the factorial of a given number.
2. Write a PHP Script to find the fibonacci series of a given number.
EXERCISE:
1. Write a XML program to validate student details(Rno, Name, college & branch)
using DTD and Schemas.
2. Write a XML program to validate book details( Title of the book, Author Name,
ISBN no & Publication) using DTD and Schemas.
9 (i) (a). A web application that takes a name as input and on submit it shows a hello
<name> page where name is taken from the request. It shows the start time at the right
top corner of the page and provides a logout button. On clicking this button, it should
show a logout page with Thank You <name > message with the duration of usage (hint:
Use session to store name and time).
PROGRAM:
login.html
<html>
<form action="home.php" method="post">
Username<input type="text" name="text1"><br>
<input type="submit" value="SignIn" name="submit">
</form>
</html>
Output of login.html:
Home.php:
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
$_SESSION['luser'] = $_POST['text1'];
$_SESSION['start'] = time();
$tm=$_SESSION['start'];
print "<p align='right'>Session started at " . date("h:i:sa",$tm) . "<br>";
print "<form action='logoutpage.php' method='post'>";
print "<input type='submit' value='Logout'></p>";
print "</form>";
print "Hello " . $_SESSION['luser'];
?>
Logoutpage.php:
<?php
session_start();
date_default_timezone_set("Asia/Calcutta");
print "<p align='right'>Session started at " . date("h:i:sa",time()) . "</p><br>";
print "Thank you " . $_SESSION['luser'];
$sessiontime = time() - $_SESSION['start'];
print "<br> Your session duration: " . $sessiontime . " seconds";
session_destroy();
?>
Output of Logoutpage.php:
Output:
Output:
USING SERVLET
Session1.html
<html>
<head> <title> SESSION LOGIN </title> </head>
<body>
<center>
<form action="http://localhost:8080/Session1/session6vib" method="get">
Enter Name: <input type="text" name="uname"> <br>
<input type="submit" value="LOGIN" name="register">
</form>
</center>
</body>
</html>
Session1.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Session1 extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,
ServletException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<form method=get action=session26vib>");
Date d=new Date();
out.println("<p align=right> Time:"+d.getTime()+"</p>");
String un=req.getParameter("uname");
HttpSession session=req.getSession();
session.setAttribute("user",un);
session.setAttribute("time",d.getTime());
out.println("Hello\t"+un);
out.println("<br><br> <input type=submit value=logout>");
out.println("</form");
}
catch(Exception e)
{
e.printStackTrace();
}
} }
DateSrv.java
import java.io.*;
import javax.servlet.*;
public class DateSrv extends GenericServlet
{
//implement service()
public void service(ServletRequest req, ServletResponse res) throws IOException,
ServletException
{
//set response content type
res.setContentType("text/html");
//get stream obj
PrintWriter pw = res.getWriter();
//write req processing logic
java.util.Date date = new java.util.Date();
pw.println("<h2>"+"Current Date & Time: " +date.toString()+"</h2>");
//close stream object
pw.close();
}
}
web.xml
<?xml version="1.0"?>
<web-app>
<servlet>
<servlet-name>Date</servlet-name>
<servlet-class>DateSrv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Date</servlet-name>
<url-pattern>/date</url-pattern>
</servlet-mapping>
</web-app>
Output:
//Reading cookies
Cookie c[]=request.getCookies();
//Displaying User name and User Password value from cookie
for(int i=0;i<c.length;i++){
pwriter.print("<br>"+c[i].getName()+": "+c[i].getValue());//printing name and value of
cookie
}
pwriter.close();
}catch(Exception exp){
System.out.println(exp);
}
}
}
web.xml
<web-app>
<display-name>Cookies Example</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>MyServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>MyServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
</web-app>
cookie.html
<html>
<head> <title> Calculator </title> </head>
<body>
<form action="http://localhost:8080/jsp/cookie1.jsp" method="post">
Enter your name:<input type="text" name="name1" placeholder="Enter name">
<input type="submit" value="Add cookie">
</form>
</center>
</body>
</html>
cookie1.jsp
<%@page language="java" import="java.sql.*" errorPage=""%>
<%
String name=request.getParameter("name1");
Cookie c1=new Cookie ("firstname",name);
response.addCookie(c1);
c1.setMaxAge(50*50);
%>
<form method="get" action="http://localhost:8080/jsp/cookie2.jsp">
<input type="submit" value="List Cookies">
</form>
cookie2.jsp
<%@page language="java" import="java.sql.*" errorPage=""%>
<title> List of Cookies </title>
<h1> List of Cookies </h1>
<%
Cookie[] cookies=request.getCookies();
%>
<table border=1>
</tr>
<%
out.println("<td> Cookie Name </td> <td> Cookie value </td>");
for(int i=0;i<cookies.length;i++)
{
out.println("<h2> <tr> <td>
"+cookies[i].getName()+"</td><td>"+cookies[i].getValue()+"</td></tr>");
}
%>
</tr>
</table>
OUTPUT:
import java.sql.*;
class MysqlCon{
public static void main(String args[]){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/sonoo","root","root");
//here sonoo is database name, root is username and password
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
OUTPUT:
AIM: To design an application that verifies user details from an xml using PHP.
PROGRAM:
db.php
Userlogin.xml:
<Authentication>
<user>
<username>cse</username>
<password>5</password>
</user>
<user>
<username>mrcet</username>
<password>mlrd</password>
</user>
</Authentication>
Loginform.php:
<html>
<head>
<title> Registration page </title>
</head>
<body bgcolor="pink">
<?php
$myxml=simplexml_load_file("Userlogin.xml");
$username=$_POST['uname'];
$password=$_POST['upwd'];
$xmlusername="";
$xmlpassword="";
for($i=0;$i<count($myxml);$i++)
{
$xmlusername=$myxml->user[$i]->username;
$xmlpassword=$myxml->user[$i]->password;
if($xmlusername==$username && $xmlpassword==$password)
{
echo "welcome $username";
die();
}
}
echo "Invalid username or password";
?>
</body>
</html>
add.php
<?php
$a = $_POST['t1'];
$b = $_POST['t2'];
if (isset($_POST['add']))
{
$c = $a + $b;
print $a . "+" . $b . "=" . $c;
}
if (isset($_POST['sub']))
{
$c = $a - $b;
print $a . "-" . $b . "=" . $c;
}
if (isset($_POST['mul']))
{
$c = $a * $b;
print $a . "*" . $b . "=" . $c;
}
if (isset($_POST['div']))
{
$c = $a / $b;
print $a . "/" . $b . "=" . $c;
}
?>
Output: