尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
Experiment: - 1
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 documentnitesh20180828_203145-1.jpg" height =" 150 pt" >
</div>
<div style="padding-left:0px;margin-top:10px; ">
<p style ="font-size:20pt; text-align: right"><a href="https://www.litlucknow.ac.in/"> Lucknow
Institute Of Technology </a></p>
<h1 style="font-size:30pt; text-align:center"><i><span style="color:Black;"><u>Curriculum
Vitae</u></i></h1>
<div style="padding-left:150px;margin-top:3px; ">
<h1 style="font-size:20pt;"><i><span style="color:black;">Nitesh Kumar Dubey</span></i></h1>
<h4>8429745207</br>
dubeynitesh2798@gmail.com</br>
mahanandpur,maharajgunj,mirzapur</br>
pin code - 221314</h4>
</div>
<div id="menu" style="background-color:white;width:150px;height:700px;float:left;">
</div>
<div id="content" style="background-color:white;float:left;width:700px;height:1800px;">
<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>
seeking a position in a growth-oriented company where I can use my skills to the</br>
advantage of the company while having the scope to develop my own skills.</p>
<h1 style="font-size:25pt;">EDUCATION AND QUALIIFICATIONS:</h1>
<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>Lucknow Institute of Technology</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>
<td>Board of Technical Education </td>
</tr>
<tr>
<td>12th </td>
<td>500</td>
<td>301</td>
<td> second</td>
<td>K. Lion school varanasi</td>
<td> Central Board of Secondary Education</td>
</tr>
<tr>
<td>MATRIC</td>
<td>600</td>
<td>528</td>
<td>first</td>
<td>Glenhill School Manduadih Varansi</td>
<td>Central Board of Secondary Education </td>
</tr>
</table>
<hr>
<h1 style="font-size:15pt;">TECHNICAL EXPERIENCE:</h1>
Languages: HTML, CSS, Java script, c,c++
Platforms: Windows 10,8,7,XP,98 Linux
Concepts: Networking, operating systems
<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>
1.learning new programming language</br>
2.Reading books</br>
3.website development
<hr>
<h1 style="font-size:15pt;">REFERENCE:</h1>
Will be provided on demand</pre>
<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.
Program: - HTML program
<html>
<head>
<title> Entry form</title>
</head>
<body bgcolor="white">
<center> <font color="Black" size="5%" style="Bell MT" ><center>Entry form of student
details</center></font>
<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>
Php connectivity program
<?php
$firstName =$_Post{['First_name'];
$last_name =$_Post{['last_name'];
$Email =$_Post{['Email'];
$password =$_Post{['password'];
$gender =$_Post{['gender'];
$mobile_number =$_Post{['mobile_number'];
$location =$_Post{['location'];
//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:workshoprule.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.
Program for JDBC:-
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);}
}
}
Program for maintaining database by sending queries
package com.java2novice.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class MyQueryUpdate {
public static void main(String[] args) {
Connection con = null;
Statement stmt = null;
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";
//count will give you how many records got updated
int count = stmt.executeUpdate(query);
System.out.println("Updated queries: "+count);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
try{
if(stmt != null) stmt.close();
if(con != null) con.close();
} 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,
mysql> create database demoprj;
Query OK, 1 row affected (4.10 sec)
mysql> use demoprj
Database changed
mysql> create table demo(id int(10), string varchar(20));
Query OK, 0 rows affected (1.93 sec)
mysql> desc demo;
Field type Null key Default Extra
id Int(10) yes NULL
string Varchar(20) yes NULL
2 rows in set (0.40 sec)
 Step 2: Implementation of required Web-pages
Create a form in HTML file, where take all the inputs required to insert data into the
database. Specify the servlet name in it, with the POST method as security is important
aspects in database connectivity.
<!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 ,"","");
Statement stmt = con.createStatement();
stmt.execute("select * from student"); // execute query in table student
ResultSet rs = stmt.getResultSet(); // get any Result that came from our query
if (rs != null)
while ( rs.next() ){
System.out.println("Name: " + rs.getInt("Age") + " ID: "+rs.getString("Course"));
}
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
Downloading the Tomcat Installer
1. Access the Tomcat Download page. Open a new browser tab or window and enter “Apache Tomcat 7
download” in the address bar. Hit the Enter key to view the search results. Select the first link in the results
from the official Apache Tomcat page.
 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:myservertomcat-.0.62.”
Part2
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 FilesJavajdk1.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 FilesJavajdk1.6.0_06” and press enter. The JAVA_HOME is set. Type the
following in the command prompt, “set JAVA_HOME = C:Program FilesJavajdk1.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 FilesJavajre7).
Part3
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:myservertomcat7.0.40conf). 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.
Part4
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:myservertomcat7.0.40bin,
and run “startup.bat”.
 When you first start the command prompt, you will be located in your personal directory.
This is typically C:Usersusername. 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”);
?>
Experiment: -9
Objective: -Install a database (Mysql or Oracle). Create a table which should contain at
least the following fields: name, password, email-id, phone number Write a java
program/servlet/JSP to connect to that database and extract data from the tables and
display them. Insert the details of the users who register with the web site, whenever
a new user clicks the submit button in the registration page.
Install a Database (Mysql or Oracle):-
Step 1: download MySQL
Download MySQL from dev.mysql.com/downloads/. Follow MySQL Community
Server, Windows and download the “Without installer” version.
As always, virus scan the file and check the its MD5 checksum using a tool such as fsum.
Step 2: extract the files
We will install MySQL to C:mysql, so extract the ZIP to your C: drive and rename the
folder from “mysql-x.x.xx-win32” to “mysql”.
MySQL can be installed anywhere on your system. If you want a lightweight installation, you
can remove every sub-folder except for bin, data, scripts and share.
Step 3: move the data folder (optional)
I recommend placing the data folder on another drive or partition to make backups
and re-installation easier. For the purposes of this example, we will create a folder
called D:MySQLdata and move the contents of C:mysqldata into it.
You should now have two folders, D:MySQLdatamysql and D:MySQLdatatest. The original
C:mysqldata folder can be removed.
Step 4: create a configuration file
MySQL provides several configuration methods but, in general, it is easiest to to
create a my.ini file in the mysql folder. There are hundreds of options to tweak MySQL
to your exact requirements, but the simplest my.ini file is:
[mysqld]
# installation directory
basedir="C:/mysql/"
# data directory
datadir="D:/MySQLdata/"
(Remember to change these folder locations if you have installed MySQL or the data folder
elsewhere.)
Step 5: test your installation
The MySQL server is started by running C:mysqlbinmysqld.exe. Open a command box
(Start > Run > cmd) and enter the following commands:
cd mysqlbin
mysqld
This will start the MySQL server which listens for requests on localhost port 3306. You can
now start the MySQL command line tool and connect to the database. Open another
command box and enter:
cd mysqlbin
mysql -u root
This will show a welcome message and the mysql> prompt. Enter “show databases;” to view
a list of the pre-defined databases.
Step 6: change the root password
The MySQL root user is an all-powerful account that can create and destroy
databases. If you are on a shared network, it is advisable to change the default
(blank) password. From the mysql> prompt, enter:
UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
FLUSH PRIVILEGES;
You will be prompted for the password the next time you start the MySQL command line.
Enter “exit” at the mysql> prompt to stop the command line client. You should now shut
down MySQL with the following command:
mysqladmin.exe -u root shutdown
Step 7: Install MySQL as a Windows service
The easiest way to start MySQL is to add it as a Windows service. From a command
prompt, enter:
cd mysqlbin
mysqld --install
Open the Control Panel, Administrative Tools, then Services and double-click MySQL. Set the
Startup type to “Automatic” to ensure MySQL starts every time you boot your PC.
Alternatively, set the Startup type to “Manual” and launch MySQL whenever you choose using
the command “net start mysql”.
Note that the Windows service can be removed using:
cd mysqlbin
mysqld –remove
Write a Program:
Registration Page:-
//Register.jsp
<pre><%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Register</title>
<script>
function validate()
{
var fullname = document.form.fullname.value;
var email = document.form.email.value;
var username = document.form.username.value;
var password = document.form.password.value;
var conpassword= document.form.conpassword.value;
if (fullname==null || fullname=="")
{
alert("Full Name can't be blank");
return false;
}
else if (email==null || email=="")
{
alert("Email can't be blank");
return false;
}
else if (username==null || username=="")
{
alert("Username can't be blank");
return false;
}
else if(password.length<6)
{
alert("Password must be at least 6 characters long.");
return false;
}
else if (password!=conpassword)
{
alert("Confirm Password should match with the Password");
return false;
}
}
</script>
</head>
<body>
<center><h2>Java Registration application using MVC and MySQL </h2></center>
<form name="form" action="RegisterServlet" method="post" onsubmit="return validate()">
<table align="center">
<tr>
<td>Full Name</td>
<td><input type="text" name="fullname" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" name="conpassword" /></td>
</tr>
<tr>
<td><%=(request.getAttribute("errMessage") == null) ? ""
: request.getAttribute("errMessage")%></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Register"></input><input
type="reset" value="Reset"></input></td>
</tr>
</table>
</form>
</body>
</html>
Registration servlet page:-
//RegisterServlet.java
package com.mvc.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mvc.bean.RegisterBean;
import com.mvc.dao.RegisterDao;
public class RegisterServlet extends HttpServlet {
public RegisterServlet() {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
//Copying all the input parameters in to local variables
String fullName = request.getParameter("fullname");
String email = request.getParameter("email");
String userName = request.getParameter("username");
String password = request.getParameter("password");
RegisterBean registerBean = new RegisterBean();
//Using Java Beans - An easiest way to play with group of related data
registerBean.setFullName(fullName);
registerBean.setEmail(email);
registerBean.setUserName(userName);
registerBean.setPassword(password);
RegisterDao registerDao = new RegisterDao();
//The core Logic of the Registration application is present here. We are going to insert user
data in to the database.
String userRegistered = registerDao.registerUser(registerBean);
if(userRegistered.equals("SUCCESS")) //On success, you can display a message to user on
Home page
{
request.getRequestDispatcher("/Home.jsp").forward(request, response);
}
else //On Failure, display a meaningful message to the User.
{
request.setAttribute("errMessage", userRegistered);
request.getRequestDispatcher("/Register.jsp").forward(request, response);
}
}
}
RegisterDao.java Page to store data
package com.mvc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.mvc.bean.RegisterBean;
import com.mvc.util.DBConnection;
public class RegisterDao {
public String registerUser(RegisterBean registerBean)
{
String fullName = registerBean.getFullName();
String email = registerBean.getEmail();
String userName = registerBean.getUserName();
String password = registerBean.getPassword();
Connection con = null;
PreparedStatement preparedStatement = null;
try
{
con = DBConnection.createConnection();
String query = "insert into users(SlNo,fullName,Email,userName,password) values (NULL,?,?,?,?)";
//Insert user details into the table 'USERS'
preparedStatement = con.prepareStatement(query); //Making use of prepared statements here to
insert bunch of data
preparedStatement.setString(1, fullName);
preparedStatement.setString(2, email);
preparedStatement.setString(3, userName);
preparedStatement.setString(4, password);
int i= preparedStatement.executeUpdate();
if (i!=0) //Just to ensure data has been inserted into the database
return "SUCCESS";
}
catch(SQLException e)
{
e.printStackTrace();
}
return "Oops.. Something went wrong there..!"; // On failure, send a message from here.
}
}
Database connectivity Page
package com.mvc.util;
import java.sql.Connection;
import java.sql.DriverManager;
public class DBConnection {
public static Connection createConnection()
{
Connection con = null;
String url = "jdbc:mysql://localhost:3306/customers"; //MySQL URL followed by the
database name
String username = "root"; //MySQL username
String password = "root123"; //MySQL password
try
{
try
{
Class.forName("com.mysql.jdbc.Driver"); //loading MySQL drivers. This differs for database
servers
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
con = DriverManager.getConnection(url, username, password); //attempting to connect to
MySQL database
System.out.println("Printing connection object "+con);
}
catch (Exception e)
{
e.printStackTrace();
}
return con;
}
}
Experiment: -10
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
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Example</title>
</head>
<body>
<form method="post" action="login.jsp">
<center>
<table border="1" width="30%" cellpadding="3">
<thead>
<tr>
<th colspan="2">Login Here</th>
</tr>
</thead>
<tbody>
<tr>
<td>User Name</td>
<td><input type="text" name="uname" value="" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" value="" /></td>
</tr>
<tr>
<td><input type="submit" value="Login" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
<tr>
<td colspan="2">Yet Not Registered!! <a
href="reg.jsp">Register Here</a></td>
</tr>
</tbody>
</table>
</center>
</form>
</body> </html>
Reg.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration</title></head>
<body>
<form method="post" action="registration.jsp">
<center>
<table border="1" width="30%" cellpadding="5">
<thead>
<tr>
<th colspan="2">Enter Information Here</th>
</tr>
</thead>
<tbody>
<tr>
<td>First Name</td>
<td><input type="text" name="fname" value="" /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lname" value="" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" value="" /></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="uname" value="" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" value="" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
<tr>
<td colspan="2">Already registered!! <a href="index.jsp">Login
Here</a></td>
</tr>
</tbody>
</table>
</center>
</form>
</body>
</html>
registration.jsp
<%@ page import ="java.sql.*" %>
<%
String user = request.getParameter("uname");
String pwd = request.getParameter("pass");
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String email = request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname",
"root", "dbpass");
Statement st = con.createStatement();
//ResultSet rs;
int i = st.executeUpdate("insert into members(first_name, last_name, email,
uname, pass, regdate) values ('" + fname + "','" + lname + "','" + email + "','"
+ user + "','" + pwd + "', CURDATE())");
if (i > 0) {
//session.setAttribute("userid", user);
response.sendRedirect("welcome.jsp");
// out.print("Registration Successfull!"+"<a href='index.jsp'>Go to Login</a>");
} else {
response.sendRedirect("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");
%>

More Related Content

What's hot

JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Html forms
Html formsHtml forms
Html forms
eShikshak
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Html Form Controls
Html Form ControlsHtml Form Controls
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Controls in asp.net
Controls in asp.netControls in asp.net
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
Document Object Model
Document Object ModelDocument Object Model
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
Piyush rai
 
Presentation on HTML
Presentation on HTMLPresentation on HTML
Presentation on HTML
satvirsandhu9
 
screen output and keyboard input in js
screen output and keyboard input in jsscreen output and keyboard input in js
screen output and keyboard input in js
chauhankapil
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
Ganga Ram
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
Abdullah Al Shiam
 
Html form tag
Html form tagHtml form tag
Html form tag
shreyachougule
 
Dom
DomDom

What's hot (20)

JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Html forms
Html formsHtml forms
Html forms
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Presentation on HTML
Presentation on HTMLPresentation on HTML
Presentation on HTML
 
screen output and keyboard input in js
screen output and keyboard input in jsscreen output and keyboard input in js
screen output and keyboard input in js
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Javascript
JavascriptJavascript
Javascript
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Html form tag
Html form tagHtml form tag
Html form tag
 
Dom
DomDom
Dom
 

Similar to Web Technology Lab files with practical

Test upload
Test uploadTest upload
Test upload
Darrell Lawson Jr.
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
sblackman
 
Responsive Email Design and Development
Responsive Email Design and DevelopmentResponsive Email Design and Development
Responsive Email Design and Development
ladyheatherly
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.
Daniel Downs
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
Anthony Montalbano
 
Ilmu sosial dasar - Pembuatan CV - HTML
Ilmu sosial dasar - Pembuatan CV  - HTMLIlmu sosial dasar - Pembuatan CV  - HTML
Ilmu sosial dasar - Pembuatan CV - HTML
IgnatiusAdityaKurnia
 
Html Hands On
Html Hands OnHtml Hands On
Html Hands On
corneliuskoo
 
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
Coulawrence
 
jQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveisjQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveis
Pablo Garrido
 
1cst
1cst1cst
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]
shafiullas
 
Getting to Know Bootstrap for Rapid Web Development
Getting to Know Bootstrap for Rapid Web DevelopmentGetting to Know Bootstrap for Rapid Web Development
Getting to Know Bootstrap for Rapid Web Development
Laurence Svekis ✔
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
Marc Grabanski
 
Tercer trabajo de drapi 02
Tercer trabajo de drapi 02Tercer trabajo de drapi 02
Tercer trabajo de drapi 02
Jhon Silva Penekita
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
ppanyong
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
ppanyong
 
Copy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazaCopy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plaza
helgawerth
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
priya Nithya
 

Similar to Web Technology Lab files with practical (20)

Test upload
Test uploadTest upload
Test upload
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
Responsive Email Design and Development
Responsive Email Design and DevelopmentResponsive Email Design and Development
Responsive Email Design and Development
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Ilmu sosial dasar - Pembuatan CV - HTML
Ilmu sosial dasar - Pembuatan CV  - HTMLIlmu sosial dasar - Pembuatan CV  - HTML
Ilmu sosial dasar - Pembuatan CV - HTML
 
Html Hands On
Html Hands OnHtml Hands On
Html Hands On
 
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
TURN YOUR CELL PHONE FROM A LIABILITY INTO AN ASSET!
 
jQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveisjQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveis
 
1cst
1cst1cst
1cst
 
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]
 
Getting to Know Bootstrap for Rapid Web Development
Getting to Know Bootstrap for Rapid Web DevelopmentGetting to Know Bootstrap for Rapid Web Development
Getting to Know Bootstrap for Rapid Web Development
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Tercer trabajo de drapi 02
Tercer trabajo de drapi 02Tercer trabajo de drapi 02
Tercer trabajo de drapi 02
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
Copy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plazaCopy of-a-walk-around-westfall-plaza
Copy of-a-walk-around-westfall-plaza
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 

More from Nitesh Dubey

HTML Presentation
HTML  PresentationHTML  Presentation
HTML Presentation
Nitesh Dubey
 
MLApproachToProgramming.ppt
MLApproachToProgramming.pptMLApproachToProgramming.ppt
MLApproachToProgramming.ppt
Nitesh Dubey
 
seminar topic of holography.ppt
seminar topic of holography.pptseminar topic of holography.ppt
seminar topic of holography.ppt
Nitesh Dubey
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
Nitesh Dubey
 
Online shopping ppt
Online shopping pptOnline shopping ppt
Online shopping ppt
Nitesh Dubey
 
Python lab manual all the experiments are available
Python lab manual all the experiments are availablePython lab manual all the experiments are available
Python lab manual all the experiments are available
Nitesh Dubey
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
Nitesh Dubey
 
Software engineering practical
Software engineering practicalSoftware engineering practical
Software engineering practical
Nitesh Dubey
 
Principal of programming language lab files
Principal of programming language lab files Principal of programming language lab files
Principal of programming language lab files
Nitesh Dubey
 
database management system lab files
database management system lab filesdatabase management system lab files
database management system lab files
Nitesh Dubey
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
Nitesh Dubey
 
industrial training report on Ethical hacking
industrial training report on Ethical hackingindustrial training report on Ethical hacking
industrial training report on Ethical hacking
Nitesh Dubey
 
Project synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendanceProject synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendance
Nitesh Dubey
 
Hrms industrial training report
Hrms industrial training reportHrms industrial training report
Hrms industrial training report
Nitesh Dubey
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
Nitesh Dubey
 
SEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project reportSEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project report
Nitesh Dubey
 
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEMsynopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
Nitesh Dubey
 
artificial intelligence ppt
artificial intelligence pptartificial intelligence ppt
artificial intelligence ppt
Nitesh Dubey
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
Nitesh Dubey
 

More from Nitesh Dubey (20)

HTML Presentation
HTML  PresentationHTML  Presentation
HTML Presentation
 
MLApproachToProgramming.ppt
MLApproachToProgramming.pptMLApproachToProgramming.ppt
MLApproachToProgramming.ppt
 
seminar topic of holography.ppt
seminar topic of holography.pptseminar topic of holography.ppt
seminar topic of holography.ppt
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
 
Online shopping ppt
Online shopping pptOnline shopping ppt
Online shopping ppt
 
Python lab manual all the experiments are available
Python lab manual all the experiments are availablePython lab manual all the experiments are available
Python lab manual all the experiments are available
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
 
Software engineering practical
Software engineering practicalSoftware engineering practical
Software engineering practical
 
Principal of programming language lab files
Principal of programming language lab files Principal of programming language lab files
Principal of programming language lab files
 
database management system lab files
database management system lab filesdatabase management system lab files
database management system lab files
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Computer Organization And Architecture lab manual
Computer Organization And Architecture lab manualComputer Organization And Architecture lab manual
Computer Organization And Architecture lab manual
 
industrial training report on Ethical hacking
industrial training report on Ethical hackingindustrial training report on Ethical hacking
industrial training report on Ethical hacking
 
Project synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendanceProject synopsis on face recognition in e attendance
Project synopsis on face recognition in e attendance
 
Hrms industrial training report
Hrms industrial training reportHrms industrial training report
Hrms industrial training report
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
 
SEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project reportSEWAGE TREATMENT PLANT mini project report
SEWAGE TREATMENT PLANT mini project report
 
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEMsynopsis report on BIOMETRIC ONLINE VOTING SYSTEM
synopsis report on BIOMETRIC ONLINE VOTING SYSTEM
 
artificial intelligence ppt
artificial intelligence pptartificial intelligence ppt
artificial intelligence ppt
 
object oriented Programming ppt
object oriented Programming pptobject oriented Programming ppt
object oriented Programming ppt
 

Recently uploaded

Microsoft Azure AD architecture and features
Microsoft Azure AD architecture and featuresMicrosoft Azure AD architecture and features
Microsoft Azure AD architecture and features
ssuser381403
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
hotchicksescort
 
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Banerescorts
 
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
yogita singh$A17
 
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Poonam Singh
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
AK47
 
Cricket management system ptoject report.pdf
Cricket management system ptoject report.pdfCricket management system ptoject report.pdf
Cricket management system ptoject report.pdf
Kamal Acharya
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
kamka4105
 
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call GirlCall Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
sapna sharmap11
 
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
nonods
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
paraasingh12 #V08
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
Guangdong Ctube Industry Co., Ltd.
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
sonamrawat5631
 
Technological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdfTechnological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdf
tanujaharish2
 
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
dABGO KI CITy kUSHINAGAR Ak47
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
DebendraDevKhanal1
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
sexytaniya455
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Tsuyoshi Horigome
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
yakranividhrini
 

Recently uploaded (20)

Microsoft Azure AD architecture and features
Microsoft Azure AD architecture and featuresMicrosoft Azure AD architecture and features
Microsoft Azure AD architecture and features
 
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
❣Unsatisfied Bhabhi Call Girls Surat 💯Call Us 🔝 7014168258 🔝💃Independent Sura...
 
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Bangalore ✔ 9079923931 ✔ Hi I Am Divya Vip Call Girl Servic...
 
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl LucknowCall Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
Call Girls In Lucknow 🔥 +91-7014168258🔥High Profile Call Girl Lucknow
 
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
 
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
🔥Independent Call Girls In Pune 💯Call Us 🔝 7014168258 🔝💃Independent Pune Esco...
 
Cricket management system ptoject report.pdf
Cricket management system ptoject report.pdfCricket management system ptoject report.pdf
Cricket management system ptoject report.pdf
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
 
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call GirlCall Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
Call Girls Goa (india) ☎️ +91-7426014248 Goa Call Girl
 
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
一比一原版(psu学位证书)美国匹兹堡州立大学毕业证如何办理
 
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls ChennaiCall Girls Chennai +91-8824825030 Vip Call Girls Chennai
Call Girls Chennai +91-8824825030 Vip Call Girls Chennai
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
 
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
🔥Young College Call Girls Chandigarh 💯Call Us 🔝 7737669865 🔝💃Independent Chan...
 
Technological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdfTechnological Innovation Management And Entrepreneurship-1.pdf
Technological Innovation Management And Entrepreneurship-1.pdf
 
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
 
Lateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptxLateral load-resisting systems in buildings.pptx
Lateral load-resisting systems in buildings.pptx
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
 
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort ServiceCuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
Cuttack Call Girls 💯Call Us 🔝 7374876321 🔝 💃 Independent Female Escort Service
 

Web Technology Lab files with practical

  • 1. Experiment: - 1 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 documentnitesh20180828_203145-1.jpg" height =" 150 pt" > </div> <div style="padding-left:0px;margin-top:10px; "> <p style ="font-size:20pt; text-align: right"><a href="https://www.litlucknow.ac.in/"> Lucknow Institute Of Technology </a></p> <h1 style="font-size:30pt; text-align:center"><i><span style="color:Black;"><u>Curriculum Vitae</u></i></h1> <div style="padding-left:150px;margin-top:3px; "> <h1 style="font-size:20pt;"><i><span style="color:black;">Nitesh Kumar Dubey</span></i></h1> <h4>8429745207</br> dubeynitesh2798@gmail.com</br> mahanandpur,maharajgunj,mirzapur</br> pin code - 221314</h4> </div> <div id="menu" style="background-color:white;width:150px;height:700px;float:left;"> </div> <div id="content" style="background-color:white;float:left;width:700px;height:1800px;"> <h1 style="font-size:20pt;">Objective</h1> <p style ="font-size:15pt; font-family:Bell MT">A motivated individual with in-depth knowledge of
  • 2. languages and development tools, </br> seeking a position in a growth-oriented company where I can use my skills to the</br> advantage of the company while having the scope to develop my own skills.</p> <h1 style="font-size:25pt;">EDUCATION AND QUALIIFICATIONS:</h1> <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>Lucknow Institute of Technology</td> <td>A.K.T.University </td> </tr> <tr> <td>Diploma</td> <td>2400</td> <td>1859</td> <td>First</td>
  • 3. <td>Mahatma jyotiba phole gov. polytechnic kaushambi </td> <td>Board of Technical Education </td> </tr> <tr> <td>12th </td> <td>500</td> <td>301</td> <td> second</td> <td>K. Lion school varanasi</td> <td> Central Board of Secondary Education</td> </tr> <tr> <td>MATRIC</td> <td>600</td> <td>528</td> <td>first</td> <td>Glenhill School Manduadih Varansi</td> <td>Central Board of Secondary Education </td> </tr> </table> <hr> <h1 style="font-size:15pt;">TECHNICAL EXPERIENCE:</h1> Languages: HTML, CSS, Java script, c,c++ Platforms: Windows 10,8,7,XP,98 Linux Concepts: Networking, operating systems <hr>
  • 4. <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> 1.learning new programming language</br> 2.Reading books</br> 3.website development <hr> <h1 style="font-size:15pt;">REFERENCE:</h1> Will be provided on demand</pre> <hr> <h1> </div> </body> </html>
  • 5. 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. Program: - HTML program <html> <head> <title> Entry form</title> </head> <body bgcolor="white"> <center> <font color="Black" size="5%" style="Bell MT" ><center>Entry form of student details</center></font> <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>
  • 6. <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> Php connectivity program <?php $firstName =$_Post{['First_name']; $last_name =$_Post{['last_name']; $Email =$_Post{['Email'];
  • 7. $password =$_Post{['password']; $gender =$_Post{['gender']; $mobile_number =$_Post{['mobile_number']; $location =$_Post{['location']; //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(); } ?>
  • 8. 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>
  • 10. 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; }
  • 11. 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)
  • 12. { 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;">
  • 13. <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" />
  • 14. <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:-
  • 15. 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:workshoprule.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>
  • 16. <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;
  • 18. 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. Program for JDBC:- 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);} } } Program for maintaining database by sending queries package com.java2novice.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class MyQueryUpdate { public static void main(String[] args) { Connection con = null;
  • 19. Statement stmt = null; 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"; //count will give you how many records got updated int count = stmt.executeUpdate(query); System.out.println("Updated queries: "+count); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ try{ if(stmt != null) stmt.close(); if(con != null) con.close(); } 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, mysql> create database demoprj; Query OK, 1 row affected (4.10 sec)
  • 20. mysql> use demoprj Database changed mysql> create table demo(id int(10), string varchar(20)); Query OK, 0 rows affected (1.93 sec) mysql> desc demo; Field type Null key Default Extra id Int(10) yes NULL string Varchar(20) yes NULL 2 rows in set (0.40 sec)  Step 2: Implementation of required Web-pages Create a form in HTML file, where take all the inputs required to insert data into the database. Specify the servlet name in it, with the POST method as security is important aspects in database connectivity. <!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.*;
  • 21. 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 ,"",""); Statement stmt = con.createStatement(); stmt.execute("select * from student"); // execute query in table student ResultSet rs = stmt.getResultSet(); // get any Result that came from our query if (rs != null) while ( rs.next() ){ System.out.println("Name: " + rs.getInt("Age") + " ID: "+rs.getString("Course")); } stmt.close(); con.close(); } catch (Exception err) { System.out.println("ERROR: " + err); } } }
  • 22. 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 Downloading the Tomcat Installer 1. Access the Tomcat Download page. Open a new browser tab or window and enter “Apache Tomcat 7 download” in the address bar. Hit the Enter key to view the search results. Select the first link in the results from the official Apache Tomcat page.  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:myservertomcat-.0.62.” Part2 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 FilesJavajdk1.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 =
  • 23. C:Program FilesJavajdk1.6.0_06” and press enter. The JAVA_HOME is set. Type the following in the command prompt, “set JAVA_HOME = C:Program FilesJavajdk1.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 FilesJavajre7). Part3 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:myservertomcat7.0.40conf). 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. Part4 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:myservertomcat7.0.40bin, and run “startup.bat”.
  • 24.  When you first start the command prompt, you will be located in your personal directory. This is typically C:Usersusername. 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.
  • 25. 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’])) {
  • 26. 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”); ?>
  • 27. Experiment: -9 Objective: -Install a database (Mysql or Oracle). Create a table which should contain at least the following fields: name, password, email-id, phone number Write a java program/servlet/JSP to connect to that database and extract data from the tables and display them. Insert the details of the users who register with the web site, whenever a new user clicks the submit button in the registration page. Install a Database (Mysql or Oracle):- Step 1: download MySQL Download MySQL from dev.mysql.com/downloads/. Follow MySQL Community Server, Windows and download the “Without installer” version. As always, virus scan the file and check the its MD5 checksum using a tool such as fsum. Step 2: extract the files We will install MySQL to C:mysql, so extract the ZIP to your C: drive and rename the folder from “mysql-x.x.xx-win32” to “mysql”. MySQL can be installed anywhere on your system. If you want a lightweight installation, you can remove every sub-folder except for bin, data, scripts and share. Step 3: move the data folder (optional) I recommend placing the data folder on another drive or partition to make backups and re-installation easier. For the purposes of this example, we will create a folder called D:MySQLdata and move the contents of C:mysqldata into it. You should now have two folders, D:MySQLdatamysql and D:MySQLdatatest. The original C:mysqldata folder can be removed. Step 4: create a configuration file MySQL provides several configuration methods but, in general, it is easiest to to create a my.ini file in the mysql folder. There are hundreds of options to tweak MySQL to your exact requirements, but the simplest my.ini file is: [mysqld] # installation directory basedir="C:/mysql/" # data directory datadir="D:/MySQLdata/" (Remember to change these folder locations if you have installed MySQL or the data folder elsewhere.) Step 5: test your installation The MySQL server is started by running C:mysqlbinmysqld.exe. Open a command box (Start > Run > cmd) and enter the following commands:
  • 28. cd mysqlbin mysqld This will start the MySQL server which listens for requests on localhost port 3306. You can now start the MySQL command line tool and connect to the database. Open another command box and enter: cd mysqlbin mysql -u root This will show a welcome message and the mysql> prompt. Enter “show databases;” to view a list of the pre-defined databases. Step 6: change the root password The MySQL root user is an all-powerful account that can create and destroy databases. If you are on a shared network, it is advisable to change the default (blank) password. From the mysql> prompt, enter: UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root'; FLUSH PRIVILEGES; You will be prompted for the password the next time you start the MySQL command line. Enter “exit” at the mysql> prompt to stop the command line client. You should now shut down MySQL with the following command: mysqladmin.exe -u root shutdown Step 7: Install MySQL as a Windows service The easiest way to start MySQL is to add it as a Windows service. From a command prompt, enter: cd mysqlbin mysqld --install Open the Control Panel, Administrative Tools, then Services and double-click MySQL. Set the Startup type to “Automatic” to ensure MySQL starts every time you boot your PC. Alternatively, set the Startup type to “Manual” and launch MySQL whenever you choose using the command “net start mysql”.
  • 29. Note that the Windows service can be removed using: cd mysqlbin mysqld –remove
  • 30. Write a Program: Registration Page:- //Register.jsp <pre><%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!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=ISO-8859-1"> <title>Register</title> <script> function validate() { var fullname = document.form.fullname.value; var email = document.form.email.value; var username = document.form.username.value; var password = document.form.password.value; var conpassword= document.form.conpassword.value; if (fullname==null || fullname=="") { alert("Full Name can't be blank"); return false; } else if (email==null || email=="") { alert("Email can't be blank"); return false; } else if (username==null || username=="") { alert("Username can't be blank");
  • 31. return false; } else if(password.length<6) { alert("Password must be at least 6 characters long."); return false; } else if (password!=conpassword) { alert("Confirm Password should match with the Password"); return false; } } </script> </head> <body> <center><h2>Java Registration application using MVC and MySQL </h2></center> <form name="form" action="RegisterServlet" method="post" onsubmit="return validate()"> <table align="center"> <tr> <td>Full Name</td> <td><input type="text" name="fullname" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Username</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" /></td>
  • 32. </tr> <tr> <td>Confirm Password</td> <td><input type="password" name="conpassword" /></td> </tr> <tr> <td><%=(request.getAttribute("errMessage") == null) ? "" : request.getAttribute("errMessage")%></td> </tr> <tr> <td></td> <td><input type="submit" value="Register"></input><input type="reset" value="Reset"></input></td> </tr> </table> </form> </body> </html> Registration servlet page:- //RegisterServlet.java package com.mvc.controller; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mvc.bean.RegisterBean; import com.mvc.dao.RegisterDao; public class RegisterServlet extends HttpServlet { public RegisterServlet() { } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  • 33. //Copying all the input parameters in to local variables String fullName = request.getParameter("fullname"); String email = request.getParameter("email"); String userName = request.getParameter("username"); String password = request.getParameter("password"); RegisterBean registerBean = new RegisterBean(); //Using Java Beans - An easiest way to play with group of related data registerBean.setFullName(fullName); registerBean.setEmail(email); registerBean.setUserName(userName); registerBean.setPassword(password); RegisterDao registerDao = new RegisterDao(); //The core Logic of the Registration application is present here. We are going to insert user data in to the database. String userRegistered = registerDao.registerUser(registerBean); if(userRegistered.equals("SUCCESS")) //On success, you can display a message to user on Home page { request.getRequestDispatcher("/Home.jsp").forward(request, response); } else //On Failure, display a meaningful message to the User. { request.setAttribute("errMessage", userRegistered); request.getRequestDispatcher("/Register.jsp").forward(request, response); } } } RegisterDao.java Page to store data package com.mvc.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import com.mvc.bean.RegisterBean;
  • 34. import com.mvc.util.DBConnection; public class RegisterDao { public String registerUser(RegisterBean registerBean) { String fullName = registerBean.getFullName(); String email = registerBean.getEmail(); String userName = registerBean.getUserName(); String password = registerBean.getPassword(); Connection con = null; PreparedStatement preparedStatement = null; try { con = DBConnection.createConnection(); String query = "insert into users(SlNo,fullName,Email,userName,password) values (NULL,?,?,?,?)"; //Insert user details into the table 'USERS' preparedStatement = con.prepareStatement(query); //Making use of prepared statements here to insert bunch of data preparedStatement.setString(1, fullName); preparedStatement.setString(2, email); preparedStatement.setString(3, userName); preparedStatement.setString(4, password); int i= preparedStatement.executeUpdate(); if (i!=0) //Just to ensure data has been inserted into the database return "SUCCESS"; } catch(SQLException e) { e.printStackTrace(); } return "Oops.. Something went wrong there..!"; // On failure, send a message from here. } } Database connectivity Page package com.mvc.util;
  • 35. import java.sql.Connection; import java.sql.DriverManager; public class DBConnection { public static Connection createConnection() { Connection con = null; String url = "jdbc:mysql://localhost:3306/customers"; //MySQL URL followed by the database name String username = "root"; //MySQL username String password = "root123"; //MySQL password try { try { Class.forName("com.mysql.jdbc.Driver"); //loading MySQL drivers. This differs for database servers } catch (ClassNotFoundException e) { e.printStackTrace(); } con = DriverManager.getConnection(url, username, password); //attempting to connect to MySQL database System.out.println("Printing connection object "+con); } catch (Exception e) { e.printStackTrace(); } return con; } }
  • 36. Experiment: -10 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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Example</title> </head> <body> <form method="post" action="login.jsp"> <center> <table border="1" width="30%" cellpadding="3"> <thead> <tr> <th colspan="2">Login Here</th> </tr> </thead> <tbody> <tr> <td>User Name</td> <td><input type="text" name="uname" value="" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="pass" value="" /></td> </tr> <tr> <td><input type="submit" value="Login" /></td> <td><input type="reset" value="Reset" /></td> </tr> <tr> <td colspan="2">Yet Not Registered!! <a href="reg.jsp">Register Here</a></td> </tr> </tbody> </table> </center> </form> </body> </html>
  • 37. Reg.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Registration</title></head> <body> <form method="post" action="registration.jsp"> <center> <table border="1" width="30%" cellpadding="5"> <thead> <tr> <th colspan="2">Enter Information Here</th> </tr> </thead> <tbody> <tr> <td>First Name</td> <td><input type="text" name="fname" value="" /></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="lname" value="" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td>User Name</td> <td><input type="text" name="uname" value="" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="pass" value="" /></td> </tr> <tr> <td><input type="submit" value="Submit" /></td> <td><input type="reset" value="Reset" /></td> </tr> <tr> <td colspan="2">Already registered!! <a href="index.jsp">Login Here</a></td> </tr> </tbody>
  • 38. </table> </center> </form> </body> </html> registration.jsp <%@ page import ="java.sql.*" %> <% String user = request.getParameter("uname"); String pwd = request.getParameter("pass"); String fname = request.getParameter("fname"); String lname = request.getParameter("lname"); String email = request.getParameter("email"); Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname", "root", "dbpass"); Statement st = con.createStatement(); //ResultSet rs; int i = st.executeUpdate("insert into members(first_name, last_name, email, uname, pass, regdate) values ('" + fname + "','" + lname + "','" + email + "','" + user + "','" + pwd + "', CURDATE())"); if (i > 0) { //session.setAttribute("userid", user); response.sendRedirect("welcome.jsp"); // out.print("Registration Successfull!"+"<a href='index.jsp'>Go to Login</a>"); } else { response.sendRedirect("index.jsp"); } %> welcome.jsp Registration is Successful. Please Login Here <a href='index.jsp'>Go to Login</a> login.jsp
  • 39. <%@ 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"); %>
  翻译: