SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Three Tier Architecture
//datainsert.java
import java.io.*;
import java.lang.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class datainsert extends
HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
Connection connection;
try{
String first1=req.getParameter("fname");
String last1=req.getParameter("lname");
String pass1=req.getParameter("pass");
String cpass1=req.getParameter("cpass");
String phno1=req.getParameter("phno");
String emailid1=req.getParameter("email");
String gender1=req.getParameter("gender");
String area1=req.getParameter("area");
String sel1=req.getParameter("sel");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:regdsn1"," "," ");
PreparedStatement pst = connection.prepareStatement("insert into regtable1
values(?,?,?,?,?,?,?,?,?)");
pst.setString(1,first1);
pst.setString(2,last1);
pst.setString(3,pass1);
pst.setString(4,cpass1);
pst.setString(5,phno1);
pst.setString(6,emailid1);
pst.setString(7,gender1);
pst.setString(8,area1);
pst.setString(9,sel1);

int i = pst.executeUpdate();
if(i!=0){
pw.println("<br>Record has been inserted");
}
else{
pw.println("failed to insert the data");
}
}
catch (Exception e){
pw.println(e);
}
}
}
//dataretrive.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class dataretrive extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException
{
/* database connection*/

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:regdsn1","","");
PrintWriter out=res.getWriter();
//out.println("<p> connection established</p>");
String first1=req.getParameter("fname");

Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from regtable1
where firstname='"+first1+"'");
if (!rs.next())
{
out.println("<html><head><title>
Hello</title></head><body> <h1>Incorrect Username and password
</h1></body><html>");
}
else
{
out.println("<html><head><title> Hello</title></head>");
out.println("<body><p> <h1>welcome to"+" "+
req.getParameter("fname")+"</h1></p>");
out.println("<table
border=2><tr><th>REGISTERDFIELDS</th><th>VALUE</th></tr>");
out.println("<tr><td>FIRST NAME</td><td>");
out.println(rs.getString(1));
out.println("</td></tr><td>LAST NAME</td><td>");
out.println(rs.getString(2));
out.println("</td></tr><td>PASSWORD</td><td>");
out.println(rs.getString(3));
out.println("</td></tr><td>CPASSWORD</td><td>");
out.println(rs.getString(4));
out.println("</td></tr><td>PHONENUMBER</td><td>");
out.println(rs.getString(5));
out.println("</td></tr><td>EMAIL-ID</td><td>");
out.println(rs.getString(6));
out.println("</td></tr><td>GENDER</td><td>");
out.println(rs.getString(7));
out.println("</td></tr><td>ADDRESS</td><td>");
out.println(rs.getString(8));
out.println("</td></tr><td>STATE</td><td>");
out.println(rs.getString(9));
out.println("</td></tr></table>");
}
rs.close();
con.close();
out.close();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}
dataretrive.html
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form method="GET" action="/dataretrive">
<p>Enter Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"
name="fname" size="20"></p>
<input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
userregistration.html
<DOCTYPE html>
<head>
<title>REGISTRATION PAGE</TITLE>
<script type="text/javascript">
function validation()
{
var a = document.form.fname.value;
var b = document.form.lname.value;
var password=document.form.pass.value;
var cpassword=document.form.cpass.value;
var c = document.form.phno.value;
var address=document.form.email.value;
var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/;

var gender = document.form.gender.value;
if(a=="" || a==null)
{
alert("Please Enter Your first Name");
document.form.fname.focus();
return false;
}
if(b=="" || b==null)
{
alert("Please Enter Your last Name");
document.form.lname.focus();
return false;
}
if(password=="" || password==null)
{
alert("Please Enter Your password");
document.form.pass.focus();
return false;
}
if (password.length < 6)
{
alert("enter minimum 6 characters");
document.form.pass.focus();
return false;
}
if(password!=cpassword)
{
alert("Please Enter Your correct password");
document.form.cpass.focus();
return false;
}

if (c==null || c=="")
{
alert("Phone no. cannot be left
blank");
document.form.phno.focus();
return false;
}

if(isNaN(c)|| c.indexOf(" ")!=-1)
{
alert("Enter numeric value");
document.form.phno.focus();
return false;
}
if (c.length < 10)
{
alert("enter 10 characters");
document.form.phno.focus();
return false;
}
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}
if ( ( form.gender[0].checked == false ) && (
form.gender[1].checked == false ) )
{
alert ( "Please choose your Gender: Male or Female" );
return false;
}
if (ErrorText= "") { form.submit() }
}
</script>
</head>
<body bgcolor="#E6E6FA">
<table>
<form name="form" method="POST" action="/datainsert" onsubmit="return
validation()">
<tr><td><STRONG><b><font
color="green">REGISTRATION:</font><b></STRONG></td></tr>
<tr><td><font color="blue">First Name</font><font
color="red">*:</font></td>
<td><input type="text" name="fname" size=20></td></tr>
<tr><td><font color="blue">Last Name</font><font
color="red">*:</font></td><td><input type="text" name="lname"
size=20></td></tr>
<tr><td><font color="blue">Password</font><font
color="red">*:</font></td><td>
<input type="password" name="pass" size=15></td></tr>
<tr><td><font color="blue">Confirm Password</font><font
color="red">*:</font></td><td>
<input type="password" name="cpass" size=15></td></tr>

<tr><td><font color="blue">PhoneNo</font><font
color="red">*:</font></td><td>
<input type="text" name="phno" size=10></td></tr>
<tr><td><font color="blue">Email-id</font><font
color="red">*:</font></td><td>
<input type="text" name="email" size=10></td></tr>
<tr><td><font color="blue">Select Gender</font><font
color="red">*:<td></font><input type="radio" name="gender" value="male"><font
color="blue">MALE:</font>
<input type="radio" name="gender" value="female"><font
color="blue">FEMALE:</font></td></tr>
<tr><td><font color="blue">Address:</font></td><td><textarea
name="area" size=20></textarea></td></tr>
<tr><td><font color="blue">Select State:</font></td><td><select
name="sel">
<option name="tn">TAMILNADU</option>
<option name="ap">ANDHARA PRADESH</option>
<option name="kl">KERALA</option>
</select>
</td></tr>
<tr><td><input type="submit" name="sub" value="Submit"></td></tr>
</tr>
</form></table>
</body>
</html>
To Create ms-access database

Click on new link- click blank database--window will open

Enter database name regdb1 save in mydocuments-click on create
Clck on create table in design view

Create number of field names based on number of registrationpage fields
And close sub window it will ask save -save table name regtable1
Again it will ask primary key yer or no -click no
Now table created if u click on regtable1 it will show fields

Close all windows now go start -settings-control panel-click on
administrative tools(if suppose not there check performance and maintance)
Click on datasource

Click on add tab
Select Microsoft Access Driver(*.mdb) click finish
Enter Data Source Name regdsn1 and click select
Select database from my documents select regdb1 and click ok-ok-ok
It will close all windows now driver connection over
Step1: Create datainsert .java file and dataretrive.java and save in
C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrcdatainsert.java
C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrcdataretrive.java
Step2: Create userregistration.html file save in
C:Program Filesapachetomcat6.0.36webappsROOTuserregistration.html
C:Program Filesapache-tomcat6.0.36webappsROOTdataretrive.html
Step3: Compile datainsert.java and dataretrive.java
Open command prompt
C:Document and Settingsadministrator>cd
Copy and paste full path upto src
C:cd C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrc
C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFsrc>javac
datainsert.java
C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFsrc>javac
dataretrive.java

Step4: create datainsert.classes and dataretrive.classes file in src (cut and past
in classes folder save file in this location
C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFclasses
Step5: Create web.xml file with web.xml coding give two files name
<web-apps>
<web-app>
<servlet>
<servlet-name>datainsert</servlet-name>
<servlet-class>datainsert</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>datainsert</servlet-name>
<url-pattern>/datainsert</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dataretrive</servlet-name>
<servlet-class>dataretrive</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dataretrive</servlet-name>
<url-pattern>/dataretrive</url-pattern>
</servlet-mapping>
</web-app>
Step6: Start apache-tomacat server double click on bin

C:Program Filesapache-tomcat6.0.36bin
Step7:after server startup open browser type url
http://localhost:8080/userregistration.html
http://localhost:8080/dataretrive.html
Three tier application

Contenu connexe

En vedette

Curso ICA-AtoM. Módulo 4. Neiva Pavezi
Curso ICA-AtoM. Módulo 4. Neiva PaveziCurso ICA-AtoM. Módulo 4. Neiva Pavezi
Curso ICA-AtoM. Módulo 4. Neiva PaveziNeiva Pavezi
 
Diversifying Your Digital Marketing Efforts | SMX East 2013
Diversifying Your Digital Marketing Efforts | SMX East 2013Diversifying Your Digital Marketing Efforts | SMX East 2013
Diversifying Your Digital Marketing Efforts | SMX East 201397th Floor
 
Contract - what roles we do
Contract - what roles we doContract - what roles we do
Contract - what roles we doNiomi Cowling
 
LeAP Leadership Accelerator Program
LeAP Leadership Accelerator Program LeAP Leadership Accelerator Program
LeAP Leadership Accelerator Program E2EPeoplePractices
 
Universidad nacional de san agustín: su historia de vergüenza
Universidad nacional de san agustín: su historia de vergüenzaUniversidad nacional de san agustín: su historia de vergüenza
Universidad nacional de san agustín: su historia de vergüenzalerikrat
 
ציפיות הלקוח, תפיסת השירות של המחר
ציפיות הלקוח, תפיסת השירות של המחרציפיות הלקוח, תפיסת השירות של המחר
ציפיות הלקוח, תפיסת השירות של המחרhachamd
 
Grafico diario del dax perfomance index para el 11 11-2011
Grafico diario del dax perfomance index para el 11 11-2011Grafico diario del dax perfomance index para el 11 11-2011
Grafico diario del dax perfomance index para el 11 11-2011Experiencia Trading
 
Aimopp For Presentation
Aimopp For PresentationAimopp For Presentation
Aimopp For PresentationJinky Quizon
 
Introduction to HTML5+CSS
Introduction to HTML5+CSSIntroduction to HTML5+CSS
Introduction to HTML5+CSSRamses Cabello
 
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...SlideTeam.net
 
Charcoal drawing portfolio 2013
Charcoal drawing portfolio 2013Charcoal drawing portfolio 2013
Charcoal drawing portfolio 2013Sharlena Wood
 

En vedette (16)

Curso ICA-AtoM. Módulo 4. Neiva Pavezi
Curso ICA-AtoM. Módulo 4. Neiva PaveziCurso ICA-AtoM. Módulo 4. Neiva Pavezi
Curso ICA-AtoM. Módulo 4. Neiva Pavezi
 
Presentation for aec
Presentation for aecPresentation for aec
Presentation for aec
 
Diversifying Your Digital Marketing Efforts | SMX East 2013
Diversifying Your Digital Marketing Efforts | SMX East 2013Diversifying Your Digital Marketing Efforts | SMX East 2013
Diversifying Your Digital Marketing Efforts | SMX East 2013
 
Contract - what roles we do
Contract - what roles we doContract - what roles we do
Contract - what roles we do
 
LeAP Leadership Accelerator Program
LeAP Leadership Accelerator Program LeAP Leadership Accelerator Program
LeAP Leadership Accelerator Program
 
Universidad nacional de san agustín: su historia de vergüenza
Universidad nacional de san agustín: su historia de vergüenzaUniversidad nacional de san agustín: su historia de vergüenza
Universidad nacional de san agustín: su historia de vergüenza
 
ציפיות הלקוח, תפיסת השירות של המחר
ציפיות הלקוח, תפיסת השירות של המחרציפיות הלקוח, תפיסת השירות של המחר
ציפיות הלקוח, תפיסת השירות של המחר
 
Grafico diario del dax perfomance index para el 11 11-2011
Grafico diario del dax perfomance index para el 11 11-2011Grafico diario del dax perfomance index para el 11 11-2011
Grafico diario del dax perfomance index para el 11 11-2011
 
весь-журнал
весь-журналвесь-журнал
весь-журнал
 
Aimopp For Presentation
Aimopp For PresentationAimopp For Presentation
Aimopp For Presentation
 
The Mall of the World
The Mall of the WorldThe Mall of the World
The Mall of the World
 
BAFC233
BAFC233BAFC233
BAFC233
 
Introduction to HTML5+CSS
Introduction to HTML5+CSSIntroduction to HTML5+CSS
Introduction to HTML5+CSS
 
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...
3 d pie chart circular puzzle with hole in center process 12 stages style 2 p...
 
Charcoal drawing portfolio 2013
Charcoal drawing portfolio 2013Charcoal drawing portfolio 2013
Charcoal drawing portfolio 2013
 
SEO and PR
SEO and PRSEO and PR
SEO and PR
 

Similaire à Three tier application

Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersSaeid Zebardast
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
Web Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseWeb Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseSunny U Okoro
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3Smita B Kumar
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Java script form validation
Java script  form validationJava script  form validation
Java script form validationAbhishekMondal42
 
javascript.pptx
javascript.pptxjavascript.pptx
javascript.pptxhasiny2
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
Web Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The ClientWeb Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The Clientgrutz
 
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j queryTraining in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j queryprav068
 
Form & frame
Form & frameForm & frame
Form & frameaminsir
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quizhnyb1002
 

Similaire à Three tier application (20)

Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
Update statement in PHP
Update statement in PHPUpdate statement in PHP
Update statement in PHP
 
Lab final
Lab finalLab final
Lab final
 
Web Application PHP and MySQL Database
Web Application PHP and MySQL DatabaseWeb Application PHP and MySQL Database
Web Application PHP and MySQL Database
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
XML Schemas
XML SchemasXML Schemas
XML Schemas
 
Java script form validation
Java script  form validationJava script  form validation
Java script form validation
 
javascript.pptx
javascript.pptxjavascript.pptx
javascript.pptx
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Web Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The ClientWeb Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The Client
 
Forms
FormsForms
Forms
 
high
highhigh
high
 
Javascripting.pptx
Javascripting.pptxJavascripting.pptx
Javascripting.pptx
 
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j queryTraining in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
 
Form & frame
Form & frameForm & frame
Form & frame
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
 

Three tier application

  • 1.
  • 2. Three Tier Architecture //datainsert.java import java.io.*; import java.lang.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class datainsert extends HttpServlet{ public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter pw = res.getWriter(); Connection connection; try{ String first1=req.getParameter("fname"); String last1=req.getParameter("lname"); String pass1=req.getParameter("pass"); String cpass1=req.getParameter("cpass"); String phno1=req.getParameter("phno"); String emailid1=req.getParameter("email"); String gender1=req.getParameter("gender"); String area1=req.getParameter("area"); String sel1=req.getParameter("sel"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection("jdbc:odbc:regdsn1"," "," "); PreparedStatement pst = connection.prepareStatement("insert into regtable1 values(?,?,?,?,?,?,?,?,?)"); pst.setString(1,first1); pst.setString(2,last1);
  • 3. pst.setString(3,pass1); pst.setString(4,cpass1); pst.setString(5,phno1); pst.setString(6,emailid1); pst.setString(7,gender1); pst.setString(8,area1); pst.setString(9,sel1); int i = pst.executeUpdate(); if(i!=0){ pw.println("<br>Record has been inserted"); } else{ pw.println("failed to insert the data"); } } catch (Exception e){ pw.println(e); } } } //dataretrive.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class dataretrive extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException { /* database connection*/ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:regdsn1","","");
  • 4. PrintWriter out=res.getWriter(); //out.println("<p> connection established</p>"); String first1=req.getParameter("fname"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from regtable1 where firstname='"+first1+"'"); if (!rs.next()) { out.println("<html><head><title> Hello</title></head><body> <h1>Incorrect Username and password </h1></body><html>"); } else { out.println("<html><head><title> Hello</title></head>"); out.println("<body><p> <h1>welcome to"+" "+ req.getParameter("fname")+"</h1></p>"); out.println("<table border=2><tr><th>REGISTERDFIELDS</th><th>VALUE</th></tr>"); out.println("<tr><td>FIRST NAME</td><td>"); out.println(rs.getString(1)); out.println("</td></tr><td>LAST NAME</td><td>"); out.println(rs.getString(2)); out.println("</td></tr><td>PASSWORD</td><td>"); out.println(rs.getString(3)); out.println("</td></tr><td>CPASSWORD</td><td>"); out.println(rs.getString(4)); out.println("</td></tr><td>PHONENUMBER</td><td>"); out.println(rs.getString(5)); out.println("</td></tr><td>EMAIL-ID</td><td>"); out.println(rs.getString(6)); out.println("</td></tr><td>GENDER</td><td>"); out.println(rs.getString(7)); out.println("</td></tr><td>ADDRESS</td><td>"); out.println(rs.getString(8)); out.println("</td></tr><td>STATE</td><td>"); out.println(rs.getString(9)); out.println("</td></tr></table>");
  • 5. } rs.close(); con.close(); out.close(); } catch(Exception e) { e.printStackTrace(); } } } dataretrive.html <html> <head> <title>Login Page</title> </head> <body> <form method="GET" action="/dataretrive"> <p>Enter Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="fname" size="20"></p> <input type="submit" value="Submit" name="B1"></p> </form> </body> </html> userregistration.html <DOCTYPE html> <head> <title>REGISTRATION PAGE</TITLE> <script type="text/javascript"> function validation() { var a = document.form.fname.value; var b = document.form.lname.value; var password=document.form.pass.value;
  • 6. var cpassword=document.form.cpass.value; var c = document.form.phno.value; var address=document.form.email.value; var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/; var gender = document.form.gender.value; if(a=="" || a==null) { alert("Please Enter Your first Name"); document.form.fname.focus(); return false; } if(b=="" || b==null) { alert("Please Enter Your last Name"); document.form.lname.focus(); return false; } if(password=="" || password==null) { alert("Please Enter Your password"); document.form.pass.focus(); return false; } if (password.length < 6) { alert("enter minimum 6 characters"); document.form.pass.focus(); return false; } if(password!=cpassword) { alert("Please Enter Your correct password"); document.form.cpass.focus(); return false; } if (c==null || c=="") {
  • 7. alert("Phone no. cannot be left blank"); document.form.phno.focus(); return false; } if(isNaN(c)|| c.indexOf(" ")!=-1) { alert("Enter numeric value"); document.form.phno.focus(); return false; } if (c.length < 10) { alert("enter 10 characters"); document.form.phno.focus(); return false; } if(reg.test(address) == false) { alert('Invalid Email Address'); return false; } if ( ( form.gender[0].checked == false ) && ( form.gender[1].checked == false ) ) { alert ( "Please choose your Gender: Male or Female" ); return false; } if (ErrorText= "") { form.submit() } } </script> </head> <body bgcolor="#E6E6FA"> <table> <form name="form" method="POST" action="/datainsert" onsubmit="return validation()">
  • 8. <tr><td><STRONG><b><font color="green">REGISTRATION:</font><b></STRONG></td></tr> <tr><td><font color="blue">First Name</font><font color="red">*:</font></td> <td><input type="text" name="fname" size=20></td></tr> <tr><td><font color="blue">Last Name</font><font color="red">*:</font></td><td><input type="text" name="lname" size=20></td></tr> <tr><td><font color="blue">Password</font><font color="red">*:</font></td><td> <input type="password" name="pass" size=15></td></tr> <tr><td><font color="blue">Confirm Password</font><font color="red">*:</font></td><td> <input type="password" name="cpass" size=15></td></tr> <tr><td><font color="blue">PhoneNo</font><font color="red">*:</font></td><td> <input type="text" name="phno" size=10></td></tr> <tr><td><font color="blue">Email-id</font><font color="red">*:</font></td><td> <input type="text" name="email" size=10></td></tr> <tr><td><font color="blue">Select Gender</font><font color="red">*:<td></font><input type="radio" name="gender" value="male"><font color="blue">MALE:</font> <input type="radio" name="gender" value="female"><font color="blue">FEMALE:</font></td></tr> <tr><td><font color="blue">Address:</font></td><td><textarea name="area" size=20></textarea></td></tr> <tr><td><font color="blue">Select State:</font></td><td><select name="sel"> <option name="tn">TAMILNADU</option> <option name="ap">ANDHARA PRADESH</option> <option name="kl">KERALA</option> </select> </td></tr> <tr><td><input type="submit" name="sub" value="Submit"></td></tr> </tr> </form></table> </body> </html>
  • 9. To Create ms-access database Click on new link- click blank database--window will open Enter database name regdb1 save in mydocuments-click on create
  • 10. Clck on create table in design view Create number of field names based on number of registrationpage fields And close sub window it will ask save -save table name regtable1 Again it will ask primary key yer or no -click no
  • 11. Now table created if u click on regtable1 it will show fields Close all windows now go start -settings-control panel-click on administrative tools(if suppose not there check performance and maintance)
  • 13. Select Microsoft Access Driver(*.mdb) click finish
  • 14. Enter Data Source Name regdsn1 and click select
  • 15. Select database from my documents select regdb1 and click ok-ok-ok It will close all windows now driver connection over Step1: Create datainsert .java file and dataretrive.java and save in C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrcdatainsert.java C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrcdataretrive.java Step2: Create userregistration.html file save in C:Program Filesapachetomcat6.0.36webappsROOTuserregistration.html C:Program Filesapache-tomcat6.0.36webappsROOTdataretrive.html Step3: Compile datainsert.java and dataretrive.java Open command prompt C:Document and Settingsadministrator>cd Copy and paste full path upto src C:cd C:Program Filesapache-tomcat6.0.36webappsROOTWEBINFsrc C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFsrc>javac datainsert.java
  • 16. C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFsrc>javac dataretrive.java Step4: create datainsert.classes and dataretrive.classes file in src (cut and past in classes folder save file in this location C:Program Filesapache-tomcat6.0.36webappsROOTWEB-INFclasses Step5: Create web.xml file with web.xml coding give two files name <web-apps> <web-app> <servlet> <servlet-name>datainsert</servlet-name> <servlet-class>datainsert</servlet-class> </servlet> <servlet-mapping> <servlet-name>datainsert</servlet-name> <url-pattern>/datainsert</url-pattern> </servlet-mapping> <servlet> <servlet-name>dataretrive</servlet-name> <servlet-class>dataretrive</servlet-class> </servlet> <servlet-mapping> <servlet-name>dataretrive</servlet-name> <url-pattern>/dataretrive</url-pattern> </servlet-mapping>
  • 17. </web-app> Step6: Start apache-tomacat server double click on bin C:Program Filesapache-tomcat6.0.36bin Step7:after server startup open browser type url
  • 19.