after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp

after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp

i ve creted registration page n login page. after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db(m developing new website,so it doesn't ve any data)... bt after storing data,thr will b data na ,so hw to retrive that data.... rpy asap plzzz,i ve to submit project in this week....

View Answers

July 13, 2011 at 12:36 PM

1)login.jsp:

<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
 alert("Enter Username!");
  return false;
}
if(password==""){
 alert("Enter Password!");
  return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Login"></td></tr>
<tr><td></td><td><a href="register.jsp">Register Here</a></td></tr>
</table>
</form>
</html>

2)check.jsp:

<%@page import="java.sql.*"%>

<%
try{
String user=request.getParameter("user");
String pass=request.getParameter("pass");
 Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
           int count=0;
          while(rs.next())
          {
                              count++;
          }

                    if(count>0){
            out.println("welcome "+user);
            Statement s=con.createStatement();
           ResultSet rst=s.executeQuery("select * from login where username='"+user+"' and password='"+pass+"'");
          while(rst.next()){
              System.out.println(rst.getString("firstname"));
            %>
            <h3>Your Account Information</h3>
            <table>
            <tr><td>FirstName:</td><td><input type="text" name="name" value="<%=rst.getString("firstname")%>"></td></tr>
            <tr><td>LastName:</td><td><input type="text" name="name" value="<%=rst.getString("lastname")%>"></td></tr>
            <tr><td>Address:</td><td><input type="text" name="name" value="<%=rst.getString("address")%>"></td></tr>
            <tr><td>Contact No:</td><td><input type="text" name="name" value="<%=rst.getString("contactNo")%>"></td></tr>
            <tr><td>Email:</td><td><input type="text" name="name" value="<%=rst.getString("email")%>"></td></tr>
           </table>
            <%
          }
          }
          else
          {
                       response.sendRedirect("login.jsp");
          }
}

catch(Exception e){
    System.out.println(e);
}
%>

July 13, 2011 at 12:37 PM

continue..

3)register.jsp:

<html>
<form method="post" action="insertdata.jsp">
<table>
<tr><td>Username:</td><td><input type="text" name="uname"></td></tr>
<tr><td>First Name:</td><td><input type="text" name="fname"></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contact"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insertdata.jsp:

<%@page import="java.sql.*,java.util.*"%>
<table>
<%
String uname=request.getParameter("uname");
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String pass=request.getParameter("pass");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");

        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("insert into login(username,password,firstname,lastname,address,contactNo,email) values('"+uname+"','"+pass+"','"+fname+"','"+lname+"','"+address+"',"+contact+",'"+email+"')");
        out.println("Data is successfully inserted into database.");
        ResultSet rs=st.executeQuery("Select * from login");
        if(rs.last()){
            %>
            <tr><td>User Name</td><td><input type="text" value="<%=rs.getString("username")%>"></td></tr>
            <tr><td>First Name</td><td><input type="text" value="<%=rs.getString("firstname")%>"></td></tr>
            <tr><td>Last Name</td><td><input type="text" value="<%=rs.getString("lastname")%>"></td></tr>
            <tr><td>Address</td><td><input type="text" value="<%=rs.getString("address")%>"></td></tr>
            <tr><td>Contact No</td><td><input type="text" value="<%=rs.getInt("contactNo")%>"></td></tr>
            <tr><td>Email</td><td><input type="text" value="<%=rs.getString("email")%>"></td></tr>
            <%
          }
                    con.close();

        }
        catch(Exception e){
        System.out.println(e);
        }
        %>
        </table>









Related Tutorials/Questions & Answers:
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp  i ve creted... the submit button,how can v store the data in db, n hw can v retrive the data frm
in registration page,hw the details wil b stored in db,n retrieved.....
in registration page,hw the details wil b stored in db,n retrieved..... ... the code in detail plzzz.....2)n hw do v knw whether that details r inserted... no data in db,after inserting user details only the data will b inserted in db,so
Advertisements
Retrive only requird data from a table in MYSQL databade to JSP file..on a field submit button.
Retrive only requird data from a table in MYSQL databade to JSP file..on a field submit button.  i have MYSQL DB,DB NAME:TRLIST, TABLE NAME:TR_LIST...;Submit> button===> i.e.,select node,package from tr_list where tr='yyy
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi..... i ve created login page n in that a registration form also.... my doubt is-when... that data will b stored in db(m using sybase). 2.also hw to retrieve the data from
no data in db
no data in db  Using the example in "Networking/web-services-database.shtml" managed to do everything as shown above but there is no data in the database. the result is "record inserted". where can the error
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi, i have created login page n in that a registration form also in jsp, my doubt is-when new user... will b stored in db(m using sybase). 2.also hw to retrieve the data from db. cn u
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB... and textbox2? into MYSQL DB
Storing and retrieving data alongwith image in mysql db using jsp
Storing and retrieving data alongwith image in mysql db using jsp  I want to store and retrieve the whole data as shown below in mysql db. I've put in my all efforts for building this jsp but I'm not able to understand where's
Can I study data science after 12th?
Can I study data science after 12th?  Hi, I am beginner in Data...: Can I study data science after 12th? Try to provide me good examples or tutorials links so that I can learn the topic "Can I study data science after 12th
Can I do data science after BA?
Can I do data science after BA?  Hi, I am beginner in Data Science... do data science after BA? Try to provide me good examples or tutorials links so that I can learn the topic "Can I do data science after BA?". Also
Can I do data science after BSC it?
Can I do data science after BSC it?  Hi, I am beginner in Data... I do data science after BSC it? Try to provide me good examples or tutorials links so that I can learn the topic "Can I do data science after BSC
Can we do data science after 12th?
Can we do data science after 12th?  Hi, I am beginner in Data... we do data science after 12th? Try to provide me good examples or tutorials links so that I can learn the topic "Can we do data science after 12th?"
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help me out..... in file create project i am entering proj details such as id name...; } } in SearchProjDAO i have to call servlet also how can i do this i have
ModuleNotFoundError: No module named 'vpxhw-db-data-uploader'
: No module named 'vpxhw-db-data-uploader' How to remove the ModuleNotFoundError... vpxhw-db-data-uploader After the installation of vpxhw-db-data-uploader python...ModuleNotFoundError: No module named 'vpxhw-db-data-uploader'  Hi
JSP,DB
JSP,DB  How to store the resultset of a query in a hashtable n retrive it into a jsp textfield!!!!!! datatable Label value id applno... in a hashtable n retriving bt dont know hw to do it?can u help me??.. My query
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my.... name is amit and password is ddave. so hw could i check whether the username &
How can I become a data scientist after BSC?
How can I become a data scientist after BSC?  Hi, I am beginner... to learn: How can I become a data scientist after BSC? Try to provide me good examples or tutorials links so that I can learn the topic "How can I become
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp   the user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having... in xml file.How can i store data entered by user in XML file and later retrieve data in another jsp page using retrieve submit button.Please tell step by step
how to retrive data grom database in jsp pages.
how to retrive data grom database in jsp pages.  sir, i have problem to retrieve data from table of the database on the html web pages , so would... immediately. i want sample code of jsp to retrieving data from table of database to html
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <...="http://struts.apache.org/tags-bean" prefix="bean"%> <%@page isELIgnored="false"%> The following details are stored in DB {pid} {pname} {price
how to featch data form db?
how to featch data form db?  how to featch data form db?   ...+'' //+'<input type="button"value="view details"/>...;' //+'<input type="button" value="view details"/>
Extract xml to store into db - JSP-Servlet
Extract xml to store into db  Hi all, I need to get the data from the xml file and store it onto the database. Is there anyway of doing this? thanks
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... of JSP Web Application demonstrating web technology concepts? Create n
for store data in data base - JSP-Servlet
)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...for store data in data base  i want to a job site, in this site user
ModuleNotFoundError: No module named 'v'
' How to remove the ModuleNotFoundError: No module named 'v' error... library. You can install v python with following command: pip install v After the installation of v python library, ModuleNotFoundError: No module
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."  Hi, How to get data from MYSQL Database tables on giving a "text" in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can... clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public url
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event... button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public url. Means anyone
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table  Hi sir... I am not getting how can i send the multiple input text box values in to an jsp file with additional values to store those values
to store data entered in html page
,reset and submit botton in form 1 after entering username and password by clicking 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
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more... links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more... links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval... file.How can i store data entered by user in XML file and later retrieve data in another jsp page using retrieve submit button.Please tell step by step instructions
help me in inserting data into db using hibernate
help me in inserting data into db using hibernate  How to insert data into dependent tables through hybernate   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/insert-data-database.shtml
Read data from Excel and insert in to DB and export data from DB to Excel
Read data from Excel and insert in to DB and export data from DB to Excel  Read data from Excel and insert in to DB and export data from DB to Excel Hi, I need to read the data from excel and I need to insert the same in to DB
How to access data yearly from DB in C# ?
How to access data yearly from DB in C# ?  how to access data yearly from database in C#. I have code but i m not able to retrieve data yearly from DB table. string date1 = dateTimePicker1.Value.Date.ToString("dd/MMM/yyyy
where is my sqlite data files(.db) will be saved?
where is my sqlite data files(.db) will be saved?  Hi, i am using SQLite with JDBC in Netbeans 7.1.1 for my project. So far, i am dealing... of SQLite will be stored in my computer? Also whether my .jar file will include the db
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
retrive data from database?
retrive data from database?  hellow i have a database sheet name..... now i want retrive sn,roll no and name and textbox like....,rllno,and name retrive
Request URl using Retrive data from dtabase
Request URl using Retrive data from dtabase  Using With GWT the user can create an event. In the create page, we have three buttons. Save as draft... clicks the Preview button, you have to create a dynamic jsp which should read
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
ModuleNotFoundError: No module named 'ctrl-v'
-v' How to remove the ModuleNotFoundError: No module named 'ctrl-v'... to install padas library. You can install ctrl-v python with following command: pip install ctrl-v After the installation of ctrl-v python library
ModuleNotFoundError: No module named 'ctrl-v'
-v' How to remove the ModuleNotFoundError: No module named 'ctrl-v'... to install padas library. You can install ctrl-v python with following command: pip install ctrl-v After the installation of ctrl-v python library
ModuleNotFoundError: No module named 'font-v'
-v' How to remove the ModuleNotFoundError: No module named 'font-v'... to install padas library. You can install font-v python with following command: pip install font-v After the installation of font-v python library
ModuleNotFoundError: No module named 'MIDAS-V'
'MIDAS-V' How to remove the ModuleNotFoundError: No module named 'MIDAS-V... to install padas library. You can install MIDAS-V python with following command: pip install MIDAS-V After the installation of MIDAS-V python library
ModuleNotFoundError: No module named 'nester_v'
'nester_v' How to remove the ModuleNotFoundError: No module named 'nester_v... to install padas library. You can install nester_v python with following command: pip install nester_v After the installation of nester_v python

Ads