Home Answers Viewqa JSP-Servlet 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

 
 


Sandhya.B
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
2 Answer(s)      a year and 10 months ago
Posted in : JSP-Servlet

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 Pages:
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
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, 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
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
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page called page1.jsp with 3 text fields... not populate the datas automatically from databse in jsp on entering name ...can u... (page1servlet.java) and bean(page1bean.java).I have another jsp page(display.jsp
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
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can insert the data successfully into database but once i give submit button...+"')"); out.println("Data is inserted successfully"); } %> 2)ajax.jsp: <%@ page
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can insert the data successfully into database but In ajax.jsp once i give the name... in dose textfields....can u help me?????? Name: Ram I entered dtls of ram
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
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
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
db
db  <%@ page import="java.sql.*" %> <%@ page import...;title>Insert title here</title> <h2><center>TELECOM STORE...;%} %> </select></td> <td><input type="submit" value
db
db  <%@ page import="java.sql.*" %> <%@ page import...;title>Insert title here</title> <h2><center>TELECOM STORE...;%} %> </select></td> <td><input type="submit" value
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
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
retrieving from db - JSP-Servlet
; Hi Retrive value from database Retrive data from...: Exception in JSP: /jsp1/mydb.jsp:25 22: if(request.getParameter("action... into books_details(book_name,author) values('"+bookname+"','"+author+"')"); 26
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
Java DB
for persistence based on standard interfaces. JDO technology can be used directly to store... Java DB       Java DB is an open source Apache Derby database supported by Sun. Java DB is completely
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page with 3 text fields name,age ,city.i populated these datas into a database table.I have another jsp page with 4 fields name, city , age and phone.Once the user enter the name, city and age should
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
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
ZF Data Update in DB
= new Application_Form_Book(); $form->submit->setLabel('Save'...;   Output: Now make necessary changes and click the save button
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
SQLGrammarException while trying to save data in db
SQLGrammarException while trying to save data in db  //hibernate cfg...; public String lname; public String email; public String reg; public... getReg() { return reg; } public void setReg(String reg
StringBuilder v/s StringBuffer - Java Beginners
StringBuilder v/s StringBuffer  Hi All, I want to know the difference...... to be created, which can be quite inefficient. StringBuilder (or StringBuffer ... often causes many temporary string objects to be created, which can be quite
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
validation before entering values into database in jsp
validation before entering values into database in jsp  Hi, my project involves entering data into database from jsp form.but before entering... complete and submit and ebter to database else cancel and get nack to form so
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
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
how to featch data form db?
how to featch data form db?  how to featch data form db?   ... page here. You may use following sample code. */ out.println...;/editor-fold> }   jsp <%-- Document : TCSBLUE Created
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILES,IF I ENTER 4 EMPLOYEE DETAILS(NAME,ID,SALARY,EMAIL) ALL THE DETAILS OF 4
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
java connecting to oracle db - JDBC
java connecting to oracle db  how to connect oracle data base...()); or you can use Class.forName("oracle.jdbc.driver.OracleDriver"); 3...)+" "+ rset.getFloat(3)+"\n"; } rs.close(); st.close(); conn.close(); } catch
JSP data after login where different users data are stored in database
and then after they can login. my question is how a user can see only his data after login...JSP data after login where different users data are stored in database ... page. Apart from this if user is not registered, then he or she can register
Need Help-How to store input parameter in DB through Java Bean - JSP-Servlet
Need Help-How to store input parameter in DB through Java Bean  Hello...(Its Java Bean) which create a connection from DB and insert the data. At run... "failed"; } } } submit.jsp: This is Submit page Hello Student Name
V - Java Terms
V - Java Terms      ... that implements a growable array of objects. Like an array, its items can be accessed... Virtual Machine is a set of computer software programs and data structure
Reg Dynamic Content in JavaScript - JDBC
Reg Dynamic Content in JavaScript  Can v transfer the details from a DataBase to the JavaScript Dynamically
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 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 &
Employee Details - JSP-Servlet
the contents of process.jsp in the home page itself without any submit button... in process.jsp, in Home Page. Because, for jsp or html elements like radio buttons or submit buttons, you can call only javascript methods, but not java methods or java
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
store and retrieve data
store and retrieve data  sir,i want to store the entering data... user can watch video and write comments.the comments are stored in a file... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
how to create a slider on jsp page n slider has values from 0-4
how to create a slider on jsp page n slider has values from 0-4  i want to create a slider on jsp page and slider has values from 0-4   Using the jquery, you can create a slider in jsp. <html> <head> <
To Retain the values entered in the text box after submit in jsp page
To Retain the values entered in the text box after submit in jsp page  ... given all those. Now my problem is how can i retain those values entered in box after submit has been done ? coz when data is displayed then the values entered
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
How to create d db for upload files using bolb i m followin dat upload file in db tutorial
How to create d db for upload files using bolb i m followin dat upload file in db tutorial  How to create d db for upload files using bolb i m...;%@ page language="java" %> <HTML> <FORM ENCTYPE="multipart/form-data
ZF Data Insert in DB
will be as follows: Now we can add new book from the above UI, and the data...How to insert values in a table in Zend Framework: It is a very common... to it, you can perform insert, update or any other activity with so much ease
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code...;form method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <...;td></td><td><input type="submit" value="Submit"></td>
Radio Buttons in DB Very Urgent - JSP-Servlet
the code.. Here When I click "View Database" Button,a JSP Page containing... the corresponding Radio Button and Submit,The Emp ID and Emp Name must...Radio Buttons in DB Very Urgent  Respected Sir/Madam, I am

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.