Web Tech Lab File A
Web Tech Lab File A
Web Tech Lab File A
TECHNOLOGY
Rooma, Kanpur (U.P.)
DEPARTMENT OF COMPUTER
SCIENCE AND ENGINEERING
(KCS-652)
Branch: CS(AI&ML)
INDEX
S.NO Program Title Performed Submitted Faculty Sign
Date Date
1. Write HTML/Java scripts to display your
CV in navigator, your Institute website,
Department Website and Tutorial
website for specific subject.
2.
Write an HTML program to design an entry
form of student details and sendit to store
at database server like SQL, Oracle or MS
Access.
<DOCTYPE HTML>
<html>
<body style="background-color:white;">
<div style="position:absolute;top:90px;left:800px;color:red;">
<p> <br><img src= "D:\nitesh document\nitesh\20180828_203145-1.jpg" height =" 150 pt" >
</div>
<h4>8429745207</br>
[email protected]</br>
mahanandpur,maharajgunj,mirzapur</br>
</div>
</div>
<h1 style="font-size:20pt;">Objective</h1>
<p style ="font-size:15pt; font-family:Bell MT">A motivated individual with in-depth knowledge of
languages and development tools, </br>
advantage of the company while having the scope to develop my own skills.</p>
<table>
<tr>
<th>Qualification</th>
<th>Maximun Marks</th>
<th>Obtained Marks</th>
<th>Division</th>
<th>Institution</th>
<th>Bord/University</th>
</tr
<tr>
<td>b.tech in progress</td>
<td> ----</td>
<td> ----</td>
<td>None</td>
<td>A.K.T.University </td>
</tr>
<tr>
<td>Diploma</td>
<td>2400</td>
<td>1859</td>
<td>First</td>
<td>Mahatma jyotiba phole gov. polytechnic kaushambi </td>
</tr>
<tr>
<td>12th </td>
<td>500</td>
<td>301</td>
<td> second</td>
</tr>
<tr>
<td>MATRIC</td>
<td>600</td>
<td>528</td>
<td>first</td>
</tr>
</table>
<hr>
<hr>
<h1 style="font-size:15pt;">PERSONAL SKILLS:</h1>
1.Honesty<br>
2.Team Spirit<br>
3.Accepting Challenges
<hr>
<h1 style="font-size:15pt;">LANGUAGES:</h1>
hindi, english
<hr>
<h1 style="font-size:15pt;">INTEREST:</h1>
2.Reading books</br>
3.website development
<hr>
<h1 style="font-size:15pt;">REFERENCE:</h1>
<hr>
<h1>
</div>
</body>
</html>
Experiment: 2
Objective: - Write an HTML program to design an entry form of student details and send
it to store at database server like SQL, Oracle or MS Access.
<h3>
<center><table border="2Px" color="white " >
<form action="connect.php" method="post ">
<table><tr><td>
First Name:<br><input type="text" name="First_name"/><br></br>
<align="center">Last Name:<br><input type="text" name="last_name/"></br><br>
Your Email address:<br><input type="text" name="Email"/><br/><br>
Create Password:<br><input type="password" name="password" /><br/><br/>
Confirm Your Password:<br><input type="password" name="password" /><br/><br>
GENDER:<br><br><input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="Female"> Female<br><br>
Birthday:<br><select name="dropdown">
<option value="Month"selected>MM</option>
<option value="1998">jan</option>
<option value="1999">feb</option>
<option value="2000">mar</option>
<option value="2001">april</option>
<option value="2002">may</option>
<option value="2003">june</option></select>
<select name="dropdown">
<option value="DD">DD</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option></select>
<select name="dropdown">
<option value="yy">YYYY </option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1997</option>
<option value="1995">1997</option>
<option value="1994">1997</option>
<option value="1993">1996</option></select><br/></br>
Mobile Number:<br><input type="text" name="mobile_number"></br><br>
Location:<br><input type="text" name="location" /><br/><br>
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" /></h1></td></tr></table></form>
</table>
</center>
</body>
</html>
//Database connection
$conn = new mysqli('localhost' ,'root','','test');
if($conn-> connect_error){
die ('connection Failed :' .$conn->connect_error );
}else{
$stmt = $conn -> Prepare("insert into registration (First_name,last_name,Email,Password,
gender, mobile_number, location)values(?,?,?,?,? ,?)");
$stmt ->bind_param("ssssi",$First_name,$last_name,$Email,$password,$gender,
$mobile_number,$location);
$stmt ->execute();
echo "data store successfully ... ";
$stmt -> close();
$conn->close();
}
?>
Experiment: 3
Objective:- Write programs using Java script for Web Page to displaybrowsers
information.
Program:-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Google map using Java script</title>
<script language=javascript>
function show()
{
document.write("Name "+navigator.appName+"<br>");
document.write("Version "+navigator.appVersion +"<br>");
document.write("Codename " +navigator.appCodeName +"<br>");
document.write("Cookie enable"+navigator.cookieEnabled +"<br>");
document.write("Java Enable"+navigator.javaEnabled +"<br>");
document.write("Mime type"+navigator.mimeTypes +"<br>");
document.write("Platform"+navigator.platform +"<br>");
document.write("Plug ins"+navigator.plugins +"<br>");
document.write("System Language"+navigator.systemLanguage +"<br>");
document.write("User language"+navigator.userAgent +"<br>");
document.write("User Agent"+navigator.userAgent +"<br>");
}
</script>
</head>
<body>
<form id="form1">
<div>
<input id="Button1" type="button" value="Click me" onclick="show()" />
</div>
</form>
</body>
</html>
Result:-
Experiment: 4
Objective:- Write programs using Java script for Web Page to displaybrowsers information
Program:-
<html>
<head>
<style>
.btn
{
width:55px;
height:50px;
background-color:green;
color:white;
font-size:25px;
margin:8px;
border-radius:15px;
}
</style>
<script>
var num1,num2,result,op;
function manageBtn(x)
{
var asc=x.charCodeAt(0); // ASCII
var tx=document.getElementById("txt");
if(asc>=48 && asc<=57)
{
if(tx.value=="0")
tx.value="";
tx.value=tx.value+x;
}
else if(asc==46)
{
var isPointFound=false;
var a=tx.value;
for(i=0;i<a.length;i++)
{
var ch=a.charAt(i);
if(ch=='.')
isPointFound=true;
}
if(isPointFound==false)
txt.value=txt.value+".";
}
else if(asc==67)
{
var a=tx.value;
tx.value=a.substring(0,a.length-1);
if(tx.value.length==0)
tx.value="0";
}
else if(asc==65)
{
txt.value="0";
}
else if(asc==43 || asc==45 || asc==42 || asc==47 || asc==37)
{
num1=parseFloat(tx.value);
op=x;
tx.value="0";
}
else if(asc==61)
{
num2=parseFloat(tx.value);
switch(op)
{
case "+":
result=num1+num2;
break;
case "-":
result=num1-num2;
break;
case "*":
result=num1*num2;
break;
case "/":
result=num1/num2;
break;
case "%":
result=(num1*100)/num2;
break;
default:
alert("Invalid Operation");
}
tx.value=result;
}
}
</script>
</head>
<body>
<div style="width:300px;
border-radius:25px;height:400px;background-color:pink;margin:0px auto;border:2px dotted
blue;padding:15px;">
<input type="text" id="txt" style="width:95%;height:40px;font-size:30px; border-radius:15px"
value="0" />
<input type="button" value="9" class="btn"
onclick="manageBtn(this.value)" />
<input type="button" value="8"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="7"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="C" onclick="manageBtn(this.value)"
class="btn" />
<input type="button" value="6"
onclick="manageBtn(this.value)"
class="btn" />
<input type="button" value="5"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="4"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="+"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="3"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="2"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="1"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="-"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="00"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="0"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="."
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="*"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="AC"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="="
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="%"
onclick="manageBtn(this.value)" class="btn" />
<input type="button" value="/"
onclick="manageBtn(this.value)" class="btn" />
<p style="text-align:center;color:Black;font-size:15px;font-weight:bold">
Developed By: Mr. Nitesh Kumar Dubey
</p>
</div>
</body>
</html>
Result:-
Experiment: 5
Objective: - Writing program in XML for creation of DTD, which specifies set of
rules.
Create a style sheet in CSS/ XSL & display the document in internet explorer.
Program:- XML code
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="D:\workshop\rule.css"?>
<books>
<heading>Welcome to XML file </heading>
<book>
<title>Title -: Web Programming</title>
<author>Author -: Chrisbates</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>
CSS code
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;
}
Result: -
Experiment: 6
Objective:- Program to illustrate JDBC connectivity. Program for maintaining database by
sending queries. Design and implement a simple servlet book query with the help of JDBC &
SQL. Create MS Access Database, Create on ODBC link, Compile & execute JAVA JDVC
Socket.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.
getConnection("jdbc:oracle:thin:@<hostname>:<port num>:<DB name>"
,"user","password");
stmt = con.createStatement();
String query = "update table emp set salary=2000 where empid=200";
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally{
try{
Design and implement a simple servlet book query with the help of JDBC & SQL
Step 1: Creation of Database and Table in MySQL
As soon as jar file is placed in the folder, create a database and table in MySQL,
<!DOCTYPE html>
<html>
<head>
<title>Insert Data</title>
</head>
<body>
<!-- Give Servlet reference to the form as an instances
GET and POST services can be according to the problem statement-->
<form action="./InsertData" method="post">
<p>ID:</p>
<!-- Create an element with mandatory name attribute,
so that data can be transfer to the servlet using getParameter() -->
<input type="text" name="id"/>
<br/>
<p>String:</p>
<input type="text" name="string"/>
<br/><br/><br/>
<input type="submit"/>
</form>
</body>
</html>
Create MS Access Database, Create on ODBC link, Compile & execute JAVA JDVC Socket.
package javaapplication1;
import java.sql.*;
public class MSaccess_archive {
public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// set this to a MS Access DB you have on your machine
String filename = "mdbTEST.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;}"; // add on to the end
// now we can get the connection from the DriverManager
Connection con = DriverManager.getConnection( database ,"","");
ResultSet rs = stmt.getResultSet(); // get any Result that came from our query
if (rs != null)
while ( rs.next() ){
stmt.close();
con.close();
}
catch (Exception err) {
System.out.println("ERROR: " + err);
}
}
}
Experiment: 7
Objective:- Assume four users user1, user2, user3 and user4 having the passwords
pwd1, pwd2, pwd3 and pwd4 respectively. Write a servlet for doing the
following. Create a Cookie and add these four user id’s and passwords to this
Cookie. 2. Read the user id and passwords entered in the Login form and
authenticate with the valuesavailable in the cookies.
Program for create cookies and authenticate during user id and password enterd
login.php
<html>
<body>
<form method=”POST” action=”setcookie.php”>
username:<input type=”text” name=”uname” id=”uname”/><br/>
password:<input type=”password” name=”pwd” id=”pwd”/><br/>
<input type=”submit” value=”submit”>
</form>
</body>
</html>
setcookie.php
<?php
setcookie(“mycookie1[user1]”,”pwd1″,time()+30);
setcookie(“mycookie1[user2]”,”pwd2″,time()+30);
setcookie(“mycookie1[user3]”,”pwd3″,time()+30);
setcookie(“mycookie1[user4]”,”pwd4″,time()+30);
$username=$_POST[‘uname’];
$passwd=$_POST[‘pwd’];
header(“location:authentication.php?uname=”.$username.”&pwd=”.$passwd);
?>
<html>
<head>
<title>
autheniticationthrrough cookies</title>
</head>
<body>
</body>
</html>
authentication.php
<?php
$username=$_GET[‘uname’];
$passwd=$_GET[‘pwd’];
$status=”no”;
if(isset($_COOKIE[‘mycookie1’]))
{
foreach($_COOKIE[‘mycookie1′] as $key=> $value)
{
if(($key==trim($username)) && ($value==$passwd))
{
$status=”yes”;
echo”welcometo “.$key;
break;
}
else
{
$status=”no”;
}
}
}
echo “<br><br><br><br><br><a href=’logout.php’>logout</a
if($status==”no”)
header(“Location:fail.php”);
?>
fail.php
<?php
echo “user username and or password invalid”;
?>
logout.php
<?php
setcookie(“mycookie1[user1]”,”pwd1″,time()-30);
setcookie(“mycookie1[user2]”,”pwd2″,time()-30);
setcookie(“mycookie1[user3]”,”pwd3″,time()-30);
setcookie(“mycookie1[user4]”,”pwd4″,time()-30);
header(“Location:login.php”);
?>
Experiment: 8
Objective: - Write a JSP which insert the details of the 3 or 4 users who register with the
web site by using registration form. Authenticate the user when he submits the
login form using the user name and password from the database.
Program :-
Index.jsp
welcome.jsp
Registration is Successful.
Please Login Here <a href='index.jsp'>Go to Login</a>
login.jsp
<%@ page import ="java.sql.*" %>
<%
String userid = request.getParameter("uname");
String pwd = request.getParameter("pass");
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname",
"root", "dbpass");
Statement st = con.createStatement();
ResultSet rs;
rs = st.executeQuery("select * from members where uname='" + userid + "'
and pass='" + pwd + "'");
if (rs.next()) {
session.setAttribute("userid", userid);
//out.println("welcome " + userid);
//out.println("<a href='logout.jsp'>Log out</a>");
response.sendRedirect("success.jsp");
} else {
out.println("Invalid password <a href='index.jsp'>try again</a>");
}
%>
success.jsp
<%
if ((session.getAttribute("userid") == null) ||
(session.getAttribute("userid") == "")) {
%>
You are not logged in<br/>
<a href="index.jsp">Please Login</a>
<%} else {
%>
Welcome <%=session.getAttribute("userid")%>
<a href='logout.jsp'>Log out</a>
<%
}
%>
logout.jsp
<%
session.setAttribute("userid", null);
session.invalidate();
response.sendRedirect("index.jsp");
%>