Professional Documents
Culture Documents
Web Programming
Features of Javascript:
By teznikal team:
Page 1
BCSL-057
Web Programming
By teznikal team:
Page 2
BCSL-057
Web Programming
By teznikal team:
Page 3
BCSL-057
Web Programming
just been saved, you will be able to drag items around, you will
see some static text suddenly turn into an edit field as you hover
over it.
By teznikal team:
Page 4
BCSL-057
Web Programming
<phone_no>011-22874411</phone_no>
<mob_no>9987222567</mob_no>
</customer>
<customer>
<name>Mr. Vipin Kumar</name>
<address>Mayur Vihar</address>
<phone_no>011-22657777</phone_no>
<mob_no>9987878777</mob_no>
</customer>
<customer>
<name>Mr. Kamalkant</name>
<address>Janak Puri</address>
<phone_no>011-24356566</phone_no>
<mob_no>9992222897</mob_no>
</customer>
</customer_list>
Programme
Name of
Students
Database Systems
MCA
M.Tech
Ramesh
Riaz
Sandeep
By teznikal team:
Page 5
BCSL-057
Web Programming
Web Programming
BCA
Cristopher
Salim
Farhin
Rajan
Ans. 3 StudentInfo.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<student_info
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="StudentInfo.xsd">
<student>
<subject>Database Systems</subject>
<programme>MCA</programme>
<name>Ramesh</name>
</student>
<student>
<subject>Database Systems</subject>
<programme>MCA</programme>
<name>Riaz</name>
</student>
<student>
<subject>Advanced Operating System</subject>
<programme>M. Tech.</programme>
<name>Sandeep</name>
</student>
<student>
<subject>Advanced Operating System</subject>
<programme>M. Tech.</programme>
<name>Cristopher</name>
</student>
<student>
<subject>Advanced Operating System</subject>
<programme>M. Tech.</programme>
<name>Salim</name>
</student>
<student>
<subject>Web Programming</subject>
<programme>BCA</programme>
By teznikal team:
Page 6
BCSL-057
Web Programming
<name>Farhin</name>
</student>
<student>
<subject>Web Programming</subject>
<programme>BCA</programme>
<name>Rajan</name>
</student>
</student_info>
StudentInfo.xsd
<?xml version="1.0"?>
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="student_info">
<xs:complexType>
<xs:sequence>
<xs:element name="subject" type="xs:string"/>
<xs:element name="programme" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
By teznikal team:
Page 7
BCSL-057
Web Programming
<book_store
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="book_store.xsd">
<book>
<title>India 2013</title>
<author>Government of India</author>
<pub_year>2013</pub_year>
<publisher>Publication Division</publisher>
<price>Rs. 410</price>
<no_of_copies>5</no_of_copies>
</book>
<book>
<title>The Casual Vacancy</title>
<author>J K Rowling</author>
<pub_year>2012</pub_year>
<publisher>Little, Brown Book Group</publisher>
<price>Rs. 850</price>
<no_of_copies>4</no_of_copies>
</book>
<book>
<title>Midnights Children</title>
<author>Salman Rushdie</author>
<pub_year>2012</pub_year>
<publisher>Vintage</publisher>
<price>Rs. 499</price>
<no_of_copies>3</no_of_copies>
</book>
<book>
<title>Inferno</title>
<author>Dan Brown</author>
<pub_year>2013</pub_year>
<publisher>Random House</publisher>
<price>Rs. 750</price>
<no_of_copies>6</no_of_copies>
</book>
<book>
<title>Wings of Fire</title>
<author>A P J Abdul Kalam</author>
By teznikal team:
Page 8
BCSL-057
Web Programming
<pub_year>2000</pub_year>
<publisher>Universities Press</publisher>
<price>Rs. 275</price>
<no_of_copies>10</no_of_copies>
</book>
<book>
<title>Turning Points</title>
<author>A P J Abdul Kalam</author>
<pub_year>2012</pub_year>
<publisher>Harper Collins</publisher>
<price>Rs. 225</price>
<no_of_copies>8</no_of_copies>
</book>
<book>
<title>Revolution 2020</title>
<author>Chetan Bhagat</author>
<pub_year>2011</pub_year>
<publisher>Rupa & Co</publisher>
<price>Rs. 140</price>
<no_of_copies>6</no_of_copies>
</book>
<book>
<title>2 States</title>
<author>Chetan Bhagat</author>
<pub_year>2012</pub_year>
<publisher>R R Sheth % Co.</publisher>
<price>Rs. 150</price>
<no_of_copies>6</no_of_copies>
</book>
<book>
<title>Indian Economy</title>
<author>Ramesh Singh</author>
<pub_year>2013</pub_year>
<publisher>McGraw Hill Education</publisher>
<price>Rs. 425</price>
<no_of_copies>5</no_of_copies>
</book>
<book>
<title>A Bend in The River</title>
By teznikal team:
Page 9
BCSL-057
Web Programming
<author>V S Naipaul</author>
<pub_year>2011</pub_year>
<publisher>Picador</publisher>
<price>Rs. 399</price>
<no_of_copies>5</no_of_copies>
</book>
</book_store>
Book_store.xsd
<?xml version="1.0"?>
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="book_store">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="pub_year" type="xs:integer"/>
<xs:element name="publisher" type="xs:string"/>
<xs:element name="price" type="xs:integer"/>
<xs:element name="no_of_copies" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
By teznikal team:
Page 10
BCSL-057
Web Programming
<html>
<head> <title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<script>
function drop(x)
{
if (document.form1.menu.value !== "null")
document.location.href = x;
}
</script>
</head>
<body>
<form name="form1">
<select
name="menu"
onChange="drop(document.form1.menu.options
[document.form1.menu.options.selectedIndex].value);">
<option>Select</option>
<option value=Hyper.html>HTML</option>
<option value=css.html>CSS</option>
<option value=sql.html>SQL</option>
<option value=db.html>Database</option>
</select>
</form>
</body>
</html>
Output
By teznikal team:
Page 11
BCSL-057
Web Programming
sequence
of
content="text/html;
By teznikal team:
Page 12
BCSL-057
Web Programming
(1).jpg")
var slideshowspeed=1000
var whichimage=0
function slideit()
{
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()
</script>
</body>
</html>
Output
By teznikal team:
Page 13
BCSL-057
Web Programming
By teznikal team:
Page 14
BCSL-057
Web Programming
}
</script>
</head>
<body>
<form name="form1" action="" method="post">
<div align="center">
<input type="button" name="Button"
onClick="count();">
<p id="a"></p>
</div>
</form>
</body>
</html>
value="Hit
Me"
By teznikal team:
Page 15
BCSL-057
Web Programming
By teznikal team:
Page 16
BCSL-057
Web Programming
if(document.images){
var image1 = new Image();
image1.src = "books.jpg";
var image2 = new Image();
image2.src = "images.jpg";
}
</script>
</head>
<body>
<p>Move your mouse over the image to see the result</p>
<a href="#" onMouseOver="document.myImage.src=image2.src;"
onMouseOut="document.myImage.src=image1.src;">
<img name="myImage" src="images.jpg" />
</a>
</body>
</html>
By teznikal team:
Page 17
BCSL-057
Web Programming
<br/>Username:
<input
type="text"
name="username"><br/>
<br/>Address:
name="address"></textarea><br/><br/>
<br/><input type="submit" value="Submit">
</form>
</center>
</body>
</html>
<textarea
Info.jsp
<!DOCTYPE
html
%@page
contentType="text/html"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>User Info</title>
</head>
<body>
<br/><br/><br/><br/><br/>
<center><h2>Information given by User:</h2>
<br/><br/>
<%
String username=request.getParameter("username");
session.setAttribute("username",username);
String address=request.getParameter("address");
session.setAttribute("address",address);
String a=session.getAttribute("username").toString();
out.println("<b>Name: </b>"+a);
String b=session.getAttribute("address").toString();
out.println("<br/><br/><b>Address: </b>"+b);
%>
</center>
</body>
</html>
Output:
By teznikal team:
Page 18
BCSL-057
Web Programming
By teznikal team:
Page 19
BCSL-057
Web Programming
<head>
By teznikal team:
Page 20
BCSL-057
Web Programming
<body>
<%! int clicks = 0; %>
<%
String param = request.getParameter("integer");
try
{
int i = Integer.parseInt(param);
clicks ++;
}
catch (NumberFormatException e)
{
}
%>
<p>Number of clicks: <%= clicks %> </p>
<form action="">
<input type="text" name="integer" value="1"/>
<input type="submit" value="submit" />
</form>
</body>
</html>
Output:
4. Create five pages of a web site having similar top and left panels.
The top should have a logo on the left and name of the organization
By teznikal team:
Page 21
BCSL-057
Web Programming
in the middle. The left should have a drop down menu. Use JSP to
include it in all the web pages.
Ans 4. Top.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>IGNOU</title>
<style type="text/css">
@import url("IGNOUCSS.css");
</style>
</head>
<body>
<div class="top">
<table><tr><td class="pic"></td>
<td><h1>Indira Gandhi National Open University</h1>
<h3>REGIONAL CENTRE DELHI-2<br>Gandhi Smriti & Darshan
Samiti Rajghat, New Delhi-110002, INDIA</h3></td></tr>
</table>
</div>
</body>
</html>
Left.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>IGNOU</title>
<script >
function drop(x)
{
if (document.form1.menu.value != "null")
{
By teznikal team:
Page 22
BCSL-057
Web Programming
document.location.href = x
}
}
</script>
<style type="text/css">
@import url("IGNOUCSS.css");
</style>
</head>
<body>
<div class="left"><br/><br/>
<form name="form1">
<select
name="menu"
onChange="drop(document.form1.menu.options[document.form1.m
enu.options.selectedIndex].value)">
<option value=Home.jsp>Home</option>
<option value=Events.jsp>Events</option>
<option value=Stu_Support.jsp>Student Support</option>
<option value=Dev_Profile.jsp>Developer Profile</option>
<option value=Feedback.jsp>Feedback</option>
</select>
</form>
</div>
</body>
</html>
Home.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>IGNOU</title>
<script >
function drop(x)
{
if (document.form1.menu.value != "null")
{
document.location.href = x
By teznikal team:
Page 23
BCSL-057
Web Programming
}
}
</script>
<style type="text/css">
@import url("IGNOUCSS.css");
</style>
</head>
<body>
<div class="left"><br/><br/>
<form name="form1">
<select
name="menu"
onChange="drop(document.form1.menu.options[document.form1.m
enu.options.selectedIndex].value)">
<option value=Home.jsp>Home</option>
<option value=Events.jsp>Events</option>
<option value=Stu_Support.jsp>Student Support</option>
<option value=Dev_Profile.jsp>Developer Profile</option>
<option value=Feedback.jsp>Feedback</option>
</select>
</form>
</div>
</body>
</html>
Events.jsp
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv="Content-Type"
charset=utf-8"/>
content="text/html;
By teznikal team:
Page 24
BCSL-057
Web Programming
<body>
<div class="container">
<%@include file= "Top.jsp"%>
<div class="container">
<%@include file= "Left.jsp"%>
<div class="content">
<div class="content"><br/><br/><br/><br/>
<table class="eve"><tr class="sc"><th class="eve"
colspan="4">Events Details</th></tr>
<tr><th class="eve">S. No.</th>
<th class="eve">Events</th>
<th class="eve">Date</th>
<th class="eve">Time</th></tr>
<tr><td>1.</td>
<td>Classical Music Recital </td>
<td>29 September 2013</td>
<td>10:00 AM</td>
</tr>
<tr class="alt"><td>2.</td>
<td>Foundation Day Celebration</td>
<td>20 October 2013</td>
<td>09:00 AM</td>
</tr>
<tr><td>3.</td>
<td>Children's Day Celebration</td>
<td>14 November 2013</td>
<td>11:00 AM</td>
</tr>
<tr class="alt"><td>4.</td>
<td>Debate Competition</td>
<td>10 December 2014</td>
<td>12:30 PM</td>
</tr>
</table>
</div>
</div>
</div></div></body></html>
By teznikal team:
Page 25
BCSL-057
Web Programming
Stu_Support.jsp
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv="Content-Type"
charset=utf-8"/>
content="text/html;
content="text/html;
By teznikal team:
Page 26
BCSL-057
Web Programming
<style type="text/css">
@import url("IGNOUCSS.css");
</style>
</head>
<body>
<div class="container">
<%@include file= "Top.jsp"%>
<div class="container">
<%@include file= "Left.jsp"%>
<div class="content">
<h3 class="cen">Developer Profile</h3>
<div class="cen"><img src="pic.jpg" width="300"
height="200"/><br/>Soni Dubey</div><br/>
<table class="eve"><tr class="sc"><th class="eve"
colspan="5">Academic Qualification</th></tr>
<tr><th class="eve">S. No.</th>
<th>Qualification</th>
<th>Board</th>
<th>Marks %</th>
<th>Year</th></tr>
<tr><td>1.</td>
<td >10th</td>
<td>CBSE</td>
<td>72.62</td>
<td>2008</td></tr>
<tr class="alt"><td>2.</td>
<td>12th</td>
<td>CBSE</td>
<td>71.55</td>
<td>2010</td></tr>
</table><br/><br/>
<table class="eve"><tr class="sc"><th
colspan="2">Projects Detail</th></tr>
<tr><th class="eve">S. No.</th>
<th class="eve">Project Name</th></tr>
<tr><td>1.</td>
<td>MakeMyDeal.com</td></tr>
By teznikal team:
Page 27
BCSL-057
Web Programming
<tr class="alt"><td>2.</td>
<td>BookMyTrip.com</td></tr>
<tr><td>3.</td>
<td>MyIndia.com</td></tr>
</table>
<ul><li>Hobbies: Reading
books & surfing net</li>
<li>Interests: Listening to music & learning
new things</li></ul>
</div>
</div></div></body></html>
Feedback.jsp
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv="Content-Type"
charset=utf-8"/>
content="text/html;
By teznikal team:
Page 28
BCSL-057
Web Programming
if (document.form1.comment.value === "") {
alert("Please write your comments.");
document.form1.comment.focus();
return false;
}
return true;
}</script>
<style type="text/css">
@import url("IGNOUCSS.css");
</style>
</head>
<body>
<div class="container">
<%@include file= "Top.jsp"%>
<div class="container">
<%@include file= "Left.jsp"%>
<div class="content">
<br/><br/><br/><br/>
<form action="" name="form1">
<fieldset class="eve"><legend class="eve1">Feedback
Form</legend>
<br/><br/>Name: <input class="right" type="text"
name="name"/>
<br/><br/>Enrollment No. (Filled in by the students
of IGNOU
only):<input class="right" type="text" name="enrol"/>
<br/><br/>Email ID:<input class="right" type="text"
name="email"/>
<br/><br/>Write your comments here:
<br/><textarea class="right"
rows="5" cols="30" name="comment"></textarea>
<br/><br/><br/><br/><br/>
<input type="submit" value="Submit" onClick="return
(verify());">
</fieldset>
</form>
By teznikal team:
Page 29
BCSL-057
Web Programming
</div>
</div></div></body></html>
IGNOUCSS.css
body{color:#000; font-size:18pt; margin:0; padding:0;font-family:
cambria;}
.top{color: white; background:green; text-align:center; fontsize:10pt;height:150px; padding-left: 20px;}
.container{width:100%}
.pic{background-image:
url('ignou-logo3.jpg');
width:298px;
height:100px;}
table{width:100%; padding:3px;}
.
left{float:left;background:darkorange;width:250px;height:750px;pa
dding-left: 5px;margin:0;}
.footer{clear:both;color:white;text-align:center;backgroundcolor:lightseagreen;font-size:15pt; }
.content{color:
green;
background-color:
pink;
float:left;
width:748px; height:750px; text-align:center; font-size:15pt;}
select{width:170px;backgroundcolor:green;color:white;height:30px;font-family:
cambria;fontsize:15pt;}
form{text-align:center;}
a{color:white; text-decoration: none;}
li{list-style-type: none;}
.sc{color:white; text-align:center;}
.eve{ border: 2px solid green;}
ul li{list-style-type: square; font-weight:bold;}
.alt{background-color: white;}
.cen{text-align: center; font-weight:bold; color:purple;}
th{background-color: green; color: white;}
.right{float:right;}
hr{background-color: red; height:2px;}
.eve1{ border: 2px solid green; font-weight:bold; color:purple; fontsize:20pt;}
.h{color:red;}
Output:
By teznikal team:
Page 30
BCSL-057
Web Programming
By teznikal team:
Page 31
BCSL-057
Web Programming
5. Create a login form and check if the user name and password
entered by the user are correct.
Ans 5.
LoginForm.html
<!DOCTYPE
html
%@page
contentType="text/html"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body >
<h1>Login Page</h1>
<center>
<h2>Signup Details</h2>
<form action="LoginCheck.jsp;" method="post">
By teznikal team:
Page 32
BCSL-057
Web Programming
LoginCheck.jsp
<!DOCTYPE
html
%@page
contentType="text/html"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if((username.equals("abcd") && password.equals("xyz")))
{
session.setAttribute("username",username);
response.sendRedirect("Home.jsp");
}
else
response.sendRedirect("Error.jsp");
%>
</body>
</html>
Home.jsp
<!DOCTYPE
html
pageEncoding="UTF-8"
errorPage="Error.jsp"%>
By teznikal team:
%@page
contentType="text/html"
Page 33
BCSL-057
Web Programming
<html>
<head>
Logout.jsp
<!DOCTYPE
html
%@page
contentType="text/html"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
session.removeAttribute("username");
session.removeAttribute("password");
By teznikal team:
Page 34
BCSL-057
Web Programming
session.invalidate();
%>
<h1>Logout was done successfully.</h1>
</body>
</html>
Error.jsp
<!DOCTYPE
html
pageEncoding="UTF-8"%>
%@page
contentType="text/html"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Some Error has occurred, Please try again later...</h1>
</body>
</html>
Output:
By teznikal team:
Page 35
BCSL-057
Web Programming
By teznikal team:
Page 36
BCSL-057
Web Programming
{
if (myform.grp[i][counter].checked)
radio_choice = true;
}
if (!radio_choice)
{
alert("Please select one.");
return (false);
}
return(true);
}
}
</script>
</head>
<body>
<h1>Quiz</h1>
<b>Give the answer of the following questions by selecting
one option for each:</b>
<br/><br/>
Q1.Which one of the following is the Capital of India?<br><br>
<form action="QuizAnswer.jsp"method="post"
name="myform" onsubmit="return check();">
<input type="radio" name="grp1" value="Delhi" >Delhi<br>
<input type="radio" name="grp1" value="Kolkata"
>Kolkata<br>
<input type="radio" name="grp1" value="Chennai"
>Chennai<br>
<input type="radio" name="grp1" value="Mumbai"
>Mumbai<br>
<input type="submit" value="Submit">
</form><br/>
Q2.What is the full form of ATM?<br><br>
<form action="QuizAnswer2.jsp"method="post"
name="myform" onsubmit="return check();">
<input type="radio" name="grp2" value="Automated Tele
Machine" >Automated Tele Machine<br>
<input type="radio" name="grp2" value="Automatic Tele
Machine" >Automatic Tele Machine<br>
By teznikal team:
Page 37
BCSL-057
Web Programming
By teznikal team:
Page 38
BCSL-057
Web Programming
By teznikal team:
Page 39
BCSL-057
Web Programming
QuizAnswer2.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String answer="Automated Teller Machine";
String s1=request.getParameter("grp2");
if(s1.equals(answer))
{
out.println("<h4>Your Answer is correct!</h4>");
}
else
{out.println("<h4>Wrong Answer! <br/><br/>Correct
Answer is : </h4>"+answer);
}
%><br/><br/>
<a href="Quiz.jsp">Back</a>
</body>
</html>
QuizAnswer3.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
By teznikal team:
Page 40
BCSL-057
Web Programming
<body>
<%
String answer="Babar";
String s1=request.getParameter("grp3");
if(s1.equals(answer))
{
out.println("<h4>Your Answer is correct!</h4>");
}
else
{out.println("<h4>Wrong Answer! <br/><br/>Correct
Answer is : </h4>"+answer);
}
%><br/><br/>
<a href="Quiz.jsp">Back</a>
</body>
</html>
QuizAnswer4.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String answer="Charles Babbage";
String s1=request.getParameter("grp4");
if(s1.equals(answer))
{
out.println("<h4>Your Answer is correct!</h4>");
}
else
By teznikal team:
Page 41
BCSL-057
Web Programming
By teznikal team:
Page 42
BCSL-057
Web Programming
Output:
By teznikal team:
Page 43
BCSL-057
Web Programming
Ans 7. Greeting.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Greeting</title>
</head>
<body>
<b> Todays Date & Time is :</b>
<% java.util.Date date = new java.util.Date();
out.println(" "+date);
java.util.Calendar calendar=java.util.Calendar.getInstance();
int hour=calendar.get(calendar.HOUR_OF_DAY);
if(hour<12){
%>
Hour is<br>
<%=hour%>
<h3>Good Morning!</h3>
<%}else if(hour>=12 && hour<17){%>
<h3>Good Afternoon!</h3>
<%}else{%>
<h3>Good Evening!</h3>
<%}%>
</body>
</html>
Output:
By teznikal team:
Page 44
BCSL-057
Web Programming
By teznikal team:
Page 45
BCSL-057
Web Programming
By teznikal team:
Page 46
BCSL-057
Web Programming
<th>Label</th>
<th>Information</th>
</tr>
</thead>
<tbody>
<tr>
<td>Employee ID :</td>
<td><input type="text" name="EmployeeID" value="" size="9"
/></td>
</tr>
<tr>
<td>Employee Name:</td>
<td><input type="text" name="EmployeeName" value="" size="25"
/> </td>
</tr>
<tr>
<td> Select Department :</td>
<td>
<select name="Dept">
<c:forEach var="row" items="${Dept.rows}">
<option value="<c:out value="${row.Department}"/>">
<c:out value="${row.Dep_Name}"/>
</option>
</c:forEach>
</select>
<sql:query var="Department" dataSource="$(mysql)">
SELECT Department, Dep_Name FROM Department
</sql:query>
<c:forEach var="row" items="${Department.rowsByIndex}">
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/>
</c:forEach>
</c:forEach>
</td>
<tr>
<td> Designation :</td>
<td><input type="text" name="Designation" value="" size="25" />
</td>
By teznikal team:
Page 47
BCSL-057
Web Programming
</tr>
<tr>
<td>Salary :</td>
<td><input type="text" name="Salary" value="" size="25" /> </td>
</tr>
<tr>
<td> EmailID :</td>
<td><input type="text" name="EmailID" value="" size="25" />
</td>
</tr>
<tr>
<td>Year of Joining :</td>
<td><input type="text" name="JoiningYear" value="" size="4" />
</td>
</tr>
</tbody>
</table>
<input
type="submit"
value="Submit
Information"
name="Submit" />
</form>
EmployeeDataInput.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:setDataSource var="mysql" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mysql"
user="netbean" password="netbean7"/>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<sql:update var="insert" dataSource="${mysql}">
INSERT
INTO
mysqlmaster
(empID,empName,Department,Designation,Salary,
EmailID,
Joining_Year)
VALUES(?,?,?,?,?,?,?);
<sql:param value="${param.EmployeeID}" />
<sql:param value="${param.EmployeeName}" />
<sql:param value="${param.Department}" />
<sql:param value="${param.Designation}" />
<sql:param value="${param.Salary}" />
<sql:param value="${param.EmailID}" />
By teznikal team:
Page 48
BCSL-057
Web Programming
By teznikal team:
Page 49
BCSL-057
Web Programming
insert into Department VALUES("Management", "Department of
Management", "Mr. Arun Kumar");
insert into Department VALUES("Account", "Department of
Accounting", "Mr. Vijay Malhotra");
insert into Department VALUES("Human Resourses", "Department of
Human Resources", "Ms. Saroj Khurana");
select* from Department;
By teznikal team:
Page 50
BCSL-057
Web Programming
<footer>
<hr>© 2013 PNBAll Right Reserved.
</footer>
</div>
</body>
</html>
CustomerInfoForm.jsp
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<sql:setDataSource var="mysql" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mysql"
user="netbean" password="netbean7"/>
<sql:query dataSource="${mysql}" var="Dept">
SELECT Department, Dep_Name from Department;
</sql:query>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<form name="InputCustomerData" action="CustomerDataInput.jsp"
method="POST">
<table border="0">
<thead>
<tr>
<th>Label</th>
<th>Information</th>
</tr>
</thead>
<tbody>
<tr>
<td>Customer ID :</td>
<td><input type="text" name="CustomerID" value="" size="9"
/></td>
</tr>
<tr>
<td>Cusotmer Name:</td>
<td><input type="text" name="CustomerName" value="" size="25"
/> </td>
</tr>
<tr>
By teznikal team:
Page 51
BCSL-057
Web Programming
By teznikal team:
Page 52
BCSL-057
Web Programming
EmployeeDataInput.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:setDataSource var="mysql" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mysql"
user="netbean" password="netbean7"/>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<sql:update var="insert" dataSource="${mysql}">
INSERT
INTO
mysqlmaster
(CustomerID,
CustomerName,
Transaction, AccountNumber, EmailID, Opening_Year)
VALUES(?,?,?,?,?,?,?);
<sql:param value="${param. CustomerID }" />
<sql:param value="${param. CustomerName }" />
<sql:param value="${param. Transaction }" />
<sql:param value="${param. AccountNumber }" />
<sql:param value="${param.EmailID}" />
<sql:param value="${param. Opening_Year }" />
</sql:update>
<sql:query var="cusotmermaster" dataSource="${mysql}">
SELECT * FROM mysqlmaster WHERE CustomerID = ? <sql:param
value="${param. CustomerID }" />;
</sql:query>
The Record Entered by you is:
<table border="1">
<!-- column headers -->
<tr>
<th> CustomerID </th>
<th> Customer Name</th>
<th> Transaction </th>
<th> AccountNumber </th>
<th>Email ID</th>
<th> Opening_Year </th>
</tr>
<!-- column data -->
<c:forEach var="row" items="${mysqlmaster.rowsByIndex}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/></td>
By teznikal team:
Page 53
BCSL-057
Web Programming
</c:forEach>
</tr>
</c:forEach>
</table>
By teznikal team:
Page 54