Experiment: - 1: Objective
Experiment: - 1: Objective
Objective:- Write HTML/Java scripts to display your CV in navigator, your Institute website,
Department Website and Tutorial website for specific subject.
Program
<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 display
browsers 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 a Java applet to display the Application Program screen i.e. calculator
and other.
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.
,"user","password");
stmt = con.createStatement();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally{
try{
} catch(Exception ex){}
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: - Install TOMCAT web server and APACHE. Access the above developed
static web pages for books web site, using these servers by putting the web pages
developed.
Program:- install TOMCATE web server and APACHE and Access them
Tomcat 7 is the latest version, though you can select earlier versions from the left menu
panel on the download page.
2. Download the installer zip file. Go down the page to find the “Binary distribution” folder
under the “7.0.62” heading. In the folder, locate “Binary Distribution/Core” heading and
click the “Zip” link to download the installer. #* The unitary file size of the zip package is
around 8MB.
3. Unzip the installer. Go to the “Download” folder of your computer and unzip the file with
WinZip or WinRAR, or whatever unzipping program you have. Avoid unzipping the folder
to the desktop, as you will find the path of the software files hard to locate later. The best
option will be to unzip to “E:\myserver.” The unzipped directory will be
“E:\myserver\tomcat-.0.62.”
Part 2
Installing Tomcat
1. Check the installation directory. Check the installed directory to ensure it contains all the
sub folders (bin, logs, webapps, work, temp, conf, and lib). These are the required
subfolders for installing the server. If any of the folder is missing, download the zip file
again.
2. Create JAVA_HOME. After checking the directory, you should create an environment
variable called “JAVA_HOME.” To do this, go to Start >> Control Panel >> System >>
Advanced System Settings. After reaching it, click the “Advanced” tab, then click
Environment Variables >> System Variables.
Select the “New” button in the System Variables menu. In the “Variable name” field, enter
“JAVA_HOME.” Enter “c:\Program Files\Java\jdk1.7.0_{xx}” in the “Variable value” field.
(Variable value is nothing but the JDK directory, you can always find this in program files.)
3. Ensure its workability. To make sure that it’s working correctly, start a command shell
and issue: set JAVA_HOME. To open the command shell, click the “Start” button and then
“All Programs”. Type the following in the command prompt, “set JAVA_HOME =
C:\Program Files\Java\jdk1.6.0_06” and press enter. The JAVA_HOME is set. Type the
following in the command prompt, “set JAVA_HOME = C:\Program Files\Java\jdk1.6.0_06”
and press enter. The JAVA_HOME is set.
4. Create JRE_HOME. At times, you may need to set JRE_HOME instead of JAVA_HOME,
like errors when using Java. If this is the case, JRE should be used. Create JRE_HOME
the same way you created Java, but remember that the JRE installed directory will be
different (C:\Program Files\Java\jre7).
Part 3
Configuring Tomcat
1. Locate the configuration files. Locate the four configuration XML files of Tomcat in the
“conf” sub-directory of the Tomcat directory (E:\myserver\tomcat7.0.40\conf). The four files
should be context.xml, tomcat-users.xml, server.xml, and web.xml file.
2. Create a backup. Before proceeding, make a backup of the configuration files. Because of
file permissions with your backup/restore, you don’t want to restore the server with
different file permissions than what was there originally.
To do this, go to Internet router >> Prompt, issue the Enable command by entering
“Enable,” and provide the required password when prompted. A page will be displayed
with your router settings. Entering “Enable” will change the prompt to Router#, which
indicates that the router is now in privileged mode. Copy the running configuration file to
the TFTP server.
Afterwards, open the configuration file with a text editor, like Textpad or Notepad. Search
for and remove any line that starts with “AAA.” Copy the configuration file from the TFTP
server to a new router in privileged (enable) mode, which has a basic configuration.
3. Enable directory listing. Open the configuration file “web.xml” in a text editor, and change
the directory listing by changing “listings” from “false” to “true” for the “default” servlet.
4. Set the TCP Port Number. Open the configuration file “server.xml” in a text editor. The
default port number of Tomcat is 8080. Now you need to change this, since the same port
number can be used by other servers like SQL Server. You may choose any number
between 1024 and 65535.
5. Enable automatic reload. Open the configuration file “context.xml” in a text editor. Here,
set reloadable=“true” to the <Context> element to enable automatic reload after the code
changes.
Part 4
Starting Tomcat
1. Run the startup. Launch the command prompt in Windows 7. Once launched, set the
current directory to “<TOMCAT_HOME>\bin”. For example, E:\myserver\tomcat7.0.40\bin,
and run “startup.bat”.
When you first start the command prompt, you will be located in your personal directory.
This is typically C:\Users\username\. With the basic navigation commands, you can set the
directory as specified in the above step.
2. Start the server. This will direct you to a new console window of the server. Read the
messages that appear on the console. Look out for the Tomcat’s port number and double-
check.
3. Access Tomcat. Open any web browser on your Windows and then enter the URL
“http://localhost:9999”. This will direct you to the Tomcat server’s welcome page. Once you
are directed to the server page, you are almost done. Now try the URL
“http://localhost:9999/examples” to view JSP and servlet examples.
4. Tomcat when you’re done. To do this, press Ctrl + C in the Tomcat console.
Experiment: -8
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 values
available 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”);
?>