for store data in data base
i want to a job site, in this site user can registered by a form..
in this form there are his information...
i use three form for it
1)for user name and password..
2)for personal detail...
3)for educational details..
by 1 and 2 i can move on three by continue.. button..
and on 3rd form i use submit button...
data of form 1 and 2 can also be store in table along with 3 form..
how can i do it... i use sql server2000
View Answers
April 20, 2010 at 3:44 PM
Hi Friend,
We have created 4 jsp files:
1)login.jsp:
<html>
<head>
<script src="valid.js" type="text/javascript"></script>
<style>
A:hover {
text-decoration: none;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;
}
A {
text-decoration: underline;
font-family:arial;
font-size:12px;
color: #000000;
BORDER: none;
}
</style>
</head>
<body>
<br><br><br>
<form name="loginform" method="post" action="checklogin.jsp" >
<table width="250px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 align="center" style="font-weight:bold;font-size:20pt;" align="center">User Login</td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td style="font-size:12pt;" align="center">Login Name</td>
<td><input type="text" name="userName" value=""></td>
</tr>
<tr>
<td style="font-size:12pt;" align="center">Password</td>
<td><input type="password" name="password" value=""></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
<tr>
<td></td>
<td align="right"><a href="register.jsp">New User?</a></td>
</tr>
</table>
</form>
</body>
</html>
2)checklogin.jsp:
<%@ page language="java" import="java.sql.*;"%>
<html>
<body>
<%
String userName = request.getParameter("userName");
String password = request.getParameter("password");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:
mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
String strQuery = "select count(*) from login where username='"+userName+"' and password='"+password+"'";
out.println(strQuery);
ResultSet rs = st.executeQuery(strQuery);
if(rs.next()) {
if(rs.getInt(1)>0) {
session.setAttribute("userid",userName);
response.sendRedirect("details.jsp");
}
else
{
response.sendRedirect("checklogin.jsp");
}
}
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
%>
</body>
</html>
April 20, 2010 at 3:47 PM
continue..
3)register.jsp:
<%@ page import="java.sql.*"%>
<html>
<body>
<br>
<form name="userform" method="post" >
<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 style="font-weight:bold;font-size:20pt;" align="center">User Registeration</td>
</tr><tr><td colspan=2> </td>
</tr><tr>
<td>First Name </td>
<td><input type="text" name="firstName" ></td>
</tr>
<tr>
<td>Last Name </td>
<td><input type="text" name="lastname"></td>
</tr>
<tr>
<td>Login Name</td>
<td><input type="text" name="userName" ></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" ></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" ></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="address" rows=5 cols=25></textarea></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type="text" name="contactNo" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Save"></td>
</tr>
</table>
</form>
</body>
</html>
<%String fname=request.getParameter("firstName");
String lname=request.getParameter("lastName");
String uname=request.getParameter("userName");
String password=request.getParameter("password");
String email=request.getParameter("email");
String address=request.getParameter("address");
String contact=request.getParameter("contactNo");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:
mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
int i=st.executeUpdate("insert into login(firstname,lastname,username,password,email,address,contactno) values('"+fname+"','"+lname+"','"+uname+"','"+password+"','"+email+"','"+address+"','"+contact+"')");
}
catch(Exception e){}
%>
<form name="form" action="details.jsp">
<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<td><input type="submit" value="continue" ></td></tr>
</table>
</form>
April 20, 2010 at 3:48 PM
continue..
4)details.jsp:
<%@ page import="java.sql.*"%>
<html>
<body>
<br>
<form method="post" >
<table width="350px" border=0 align="center" style="background-color:ffeeff;">
<tr>
<td colspan=2 style="font-weight:bold;font-size:20pt;" align="center">Education Details</td>
</tr>
<tr>
<td>Highest Qualification</td>
<td><input type="text" name="qualification" ></td>
</tr>
<tr>
<td>Specialization</td>
<td><input type="text" name="specialization"></td>
</tr>
<tr>
<td>Year Of Passing</td>
<td><input type="text" name="year" ></td>
</tr>
<tr>
<td>Institute</td>
<td><input type="text" name="institute" ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Save Details"></td>
</tr>
</table>
</form>
</body>
</html>
<%String qua=request.getParameter("qualification");
String special=request.getParameter("specialization");
String year=request.getParameter("year");
String institute=request.getParameter("institute");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:
mysql://localhost:3306/test","root","root";);
Statement st = conn.createStatement();
int i=st.executeUpdate("insert into education(qualification,specialization,year,instatitute) values('"+qua+"','"+special+"','"+year+"','"+institute+"')");
}
catch(Exception e){}
%>
Thanks
Related Tutorials/Questions & Answers:
for store data in data base - JSP-Servletfor
store data in
data base i want to a job site, in this site user can registered by a form..
in this form there are his information...
i use.....
and on 3rd form i use submit button...
data of form 1 and 2 can also be
store Advertisements
data basedata base how to connect coding in
data base ?
The given code connects JSP page to database. You need to import the mysql connection jar file to jdk as well as to the lib of tomcat. Moreover you need to set classpath
DATA BASEDATA BASE Create a program to establish a connection to the PCTBC... the
data using a J Table.
Here is a code that connects to MySql... main(String[] args) {
Vector columnNames = new Vector();
Vector
data = new Vector
store and retrieve datastore and retrieve data sir,i want to
store the entering
data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write
data into word file
For this, poi-scratchpad-3.7-20101029.jar is needed
Java Xml Data Store be followed up and/or purchased.
You will need to
store the
data in a local binary... the implementation needs to change later on (perhaps they might decide to
store the
data...Java Xml
Data Store I have to do this project and i'm finding it so
Data base ConnectivityData base Connectivity How to configure JDBC connection for Oracle
data base.In configuring it is asking select
Data server name and TNS.I typed Oracle for
Data Server Name and IN TNS what to type?
I pulled the list for TNS
to store data entered in html pageto
store data entered in html page i want to a job site... submit we have to move to form 2 on there we have enter text
data in the textfield after that by clicking submit button
data enter in form 1 and 2 should
Data base related questionData base related question sir my table has only one element(that is pno),i am using ms-access as backend.
i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology.
please
store data from a variable in mysql?store data from a variable in mysql? sir
last time asked you tell me how to retrieve
data from a database mysql and
store it in an int variable in order to apply some calculation on it, but now i want to
store the result
JSP data base validationJSP
data base validation please explain how to validate form input string with database n also how its notify that entered
data exists already... bol = ps.execute();
out.println("
Data Added Successfully
project in JSP and XML(to store data)project in JSP and XML(to
store data) I need to complete an assignment in JSP and using XML as Database ,Please help me to complete this assignment.Ill be very very thankful to you,i am new to JSP.Please provide full code
Data base - JDBCData base I want to do this
Inserting a record with Object type column using PreparedStatement
but wht should b the column datatype
this is te...");
con.close();
}//main
}//class
For this should i create a user defined
data type
J2ME Record Data Base J2ME Record
Data Base
This Application is used to explain how to
store data in the database...
the RecordStore class. The RecordStore class is used to get the
data through
JSP and XML .data store nd retrieveJSP and XML .
data store nd retrieve I have made a form in jsp having emp id, projectname and emp name.I want to
store data related to employee in xml file.How can i
store data entered by user in XML file and later retrieve
data how to store data in XML file - JSP-Servlethow to
store data in XML file hi
i have to
store the
data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that? Hi friend
read text file and store the data in mysql - JDBCread text file and
store the
data in mysql when we
store the
data in mysql table from text file its
store the
data from new line to new column. how to
store the
data in different column from a single line of text file.
Store data in HTML forms from Excel sheetStore data in HTML forms from Excel sheet I have a excel file having multiple coloums, and having one Html page having forms corrospoding to excel coloums.
I want to auto fill up the excel
data into html forms,
Any one please
how to store data in a text file - Java Beginnershow to
store data in a text file Hi friends,
I want to know, how we can save the
data in a .txt file using swings....... for example, i want to
store the arraylist
data of swing program into a text file.......and also i want
Retrieving data from data base using jsp combo boxRetrieving
data from
data base using jsp combo box Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
datadata
data Handling AOP
datadata Handling
data in AOP
datadata handling examples in AOP Model
data handling examples in AOP Model
data base question - Java Interview Questionsdata base question first we create a table with out create primary kay,after that i want to create same record with primary key,but no duplicate record,no deletion and after creation. Hi,
Query to create
insert excel value in to oracle data baseinsert excel value in to oracle
data base Hi All
I am using...);
System.out.println("
Data is inserted...,
You can read the
data from the excel file using JDBC. For this you need
Struts2 and Hibernate Fetch Data Base ValueStruts2 and Hibernate Fetch
Data Base Value Hello Sir,
I am...;AdminProvideLeave>(); try {
> Query
q = session.createQuery("from
>...;AdminLeavePojo> adlp = null;
> try { Query
q =
> session.createQuery