BCA WT Lab Manual
BCA WT Lab Manual
6th SEMESTER
LAB MANUAL
SUBJECT CODE: 604
SESSION: 2019 – 2020
Prepared By:
Sanjay Kumar
(Assistant Professor, Department of Computer Science and Engineering)
Web Technology Lab Manual 604
LIST OF EXPERIMENTS:
Exp. No Title
3 Write an HTML program to create some windows controls for data input.
<html>
<head>
<title>VVIT – List Demo</title>
</head>
<body>
<ol>
<li>Static site
<ol type="a">
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ol>
</li>
<li>Dynamic Site
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
<li>Server Side Scripting
<ol type="i">
<li>PHP</li>
<li>JSP</li>
<li>ASP</li>
</ol>
</li>
</ul>
</li>
</ol>
</body>
</html>
Ans.
<html>
<body>
<table border="1" bordercolor="#FF0000" align="center" width="300"
cellspacing="6" cellpadding="4">
<tr>
<td colspan="3">Student Details</td>
</tr>
<tr>
<th>Roll</th>
<th>Name</th>
<th>Marks</th>
Web Technology Lab Manual 604
</tr>
<tr>
<td>80812</td>
<td>Akshay</td>
<td>25</td>
</tr>
<tr>
<td>80813</td>
<td>Sumit Kumar</td>
<td>85</td>
</tr>
<tr>
<td>80814</td>
<td>Ravi Kumar</td>
<td>45</td>
</tr>
</table></body>
</html>
Q3. Write an HTML program to create some windows controls for data input.
Ans.
<html>
<body>
<h1 align="center">Windows All Controls Demo</h1>
<tr>
<td align="left">Hobbies</td>
<td><input type="checkbox">Sports<input type="checkbox">
Music<input type="checkbox">Others
</td>
</tr>
<tr>
<td align="left">Address</td>
<td><textarea rows="5" cols="22"></textarea>
</td>
</tr>
<tr>
<td align="left">Course</td>
<td>
<select>
<option>B. Tech</option>
<option>BCA</option>
<option>BBA</option>
<option>M. Tech</option>
<option> &nbs
p; &nbs
p; </option>
</select>
</td>
</tr>
<tr>
<td>Select Photo(.jpg,.png)</td>
<td align="left"><input type="file"></td>
</tr>
<tr>
<td>Upload Resume(.pdf,.docx)</td>
<td align="left"><input type="file"></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"> </td>
</tr>
<tr>
<td colspan="2"><input type="checkbox">I agree that above info........</td>
Web Technology Lab Manual 604
</tr>
<tr>
<td align="right"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="right"><input type="submit" value="Register"></td>
<td align="left"><input type="reset" value="Clear"></td>
</tr>
</table>
</body>
</html>
Ans.
<html>
<head>
<script>
function fun()
{
alert("Hello from Javascript");
var fnum=document.getElementById("fnum").value;
var snum=document.getElementById("snum").value;
var res=Number(fnum)+Number(snum);
document.getElementById("res").value=res;
}
</script>
<body>
<table align="center" width="300" border="0">
<tr>
<td align="left">Enter First Number</td>
<td><input type="text" name="fnum" id="fnum"></td>
</tr>
<tr>
<td align="left">Enter Second Number</td>
<td><input type="text" name="snum" id="snum"></td> </tr>
<tr>
<td align="left">Result</td>
<td><input type="text" name="res" id="res"></td>
</tr>
<tr>
<td align="right"><input type="button" value="Add" onClick="fun()"></td>
<td align="left"><input type="reset" value="Clear"></td>
</tr>
</table>
</body>
</html>
Web Technology Lab Manual 604
</script>
<body>
<table align="center" width="300" border="0">
<tr>
<td align="left">Enter First Number</td>
<td><input type="text" name="fnum" id="fnum"></td>
</tr>
<tr>
<td align="left">Enter Second Number</td>
<td><input type="text" name="snum" id="snum"></td> </tr>
<tr>
<td align="left">Result</td>
<td><input type="text" name="res" id="res"></td>
</tr>
<tr>
<td align="right"><input type="button" value="Add" onClick="fun()"></td>
<td align="left"><input type="reset" value="Clear"></td>
</tr>
</table>
</body>
</html>
Web Technology Lab Manual 604
document.getElementById("uid").focus();
return false;
}
if(document.getElementById("pwd").value=="")
{
alert("Enter Password");
document.getElementById("pwd").focus();
return false;
var uid=document.getElementById("uid").value;
var pwd=document.getElementById("pwd").value;
xmlObj=new XMLHttpRequest();
xmlObj.onreadystatechange=function()
{
if(xmlObj.readyState==4 && xmlObj.status==200)
{
document.getElementById("error").innerHTML=xmlObj.responseText;
}
}
xmlObj.send();
}
</script>
<style>
.error
{
color:#F00;
font-size:16px;
}
</style>
</head>
Web Technology Lab Manual 604
<body>
<center>
User ID<input type="text" name="uid" id="uid" />
<br /><br />
Password<input type="password" name="pwd" id="pwd" />
<br /><br />
<input type="submit" value="Login" onclick="return validate()" />
<input type="reset" value="Clear" />
<div id="error" class="error"></div>
</center>
</body>
</html>
Ans.
demo.jsp file
<html>
<head>
<title>JSP Demo</title>
</head>
<body>
<%
out.print(“Hello from JSP Block.”);
%>
</body>
</html>
Ans.
<html>
<head>
<title>Try...Catch Example</title>
</head>
<body>
<%
try {
int i = 1;
i = i / 0;
out.println("The answer is " + i);
}
catch (Exception e) {
out.println("An exception occurred: " + e.getMessage());
}
%>
</body>
</html>
Web Technology Lab Manual 604
Ans.
<%
Cookie firstName = new Cookie("first_name",
request.getParameter("first_name"));
Cookie lastName = new Cookie("last_name",
request.getParameter("last_name"));
firstName.setMaxAge(60*60*24);
lastName.setMaxAge(60*60*24);
response.addCookie( firstName );
response.addCookie( lastName );
%>
<html>
<head>
<title>Setting Cookies</title>
</head>
<body>
<center>
<h1>Setting Cookies</h1>
</center>
<ul>
<li><p><b>First Name:</b>
<%= request.getParameter("first_name")%>
</p></li>
<li><p><b>Last Name:</b>
<%= request.getParameter("last_name")%>
</p></li>
</ul>
</body>
</html>
Q10. Write a program in JSP to access a sample database using JDBC driver.
Ans.
<%@ page import = "java.io.*,java.util.*,java.sql.*"%>
<%@ page import = "javax.servlet.http.*,javax.servlet.*" %>
Web Technology Lab Manual 604
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>
<html>
<head>
<title>SELECT Operation</title>
</head>
<body>
<sql:setDataSource var = "snapshot" driver = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost/TEST"
user = "root" password = "pass123"/>
</body>
</html>