JSP data after login where different users data are stored in database

JSP data after login where different users data are stored in database

hey..i have a login page where different users first registered and then after they can login. my question is how a user can see only his data after login where different users data are stored in database,plz...provide me answer its very urgent

View Answers

June 5, 2012 at 12:35 PM

The given code accepts username and password to check whether the user is valid or not. If the user is valid, whole record of that particular user will get retrieved from the database and displayed it on the welcome page. Apart from this if user is not registered, then he or she can register himself first and then login.

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">New User: 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 register where username='"+user+"' and password='"+pass+"'");
           int count=0;
           while(rs.next()){
           count++;
          }
          if(count>0){
           out.println("welcome "+user);
           %>
           <table>
            <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>User Name:</td><td><input type="text" value="<%=rs.getString("username")%>"></td></tr>
            <tr><td>Date Of Birth</td><td><input type="text" value="<%=rs.getString("dob")%>"></td></tr>
            <tr><td>Age:</td><td><input type="text" value="<%=rs.getInt("age")%>"></td></tr>
            <tr><td>Email</td><td><input type="text" value="<%=rs.getString("email")%>"></td></tr>
            <tr><td>Address:</td><td><input type="text" value="<%=rs.getString("address")%>"></td></tr>
            <tr><td>Country</td><td><input type="text" value="<%=rs.getString("country")%>"></td></tr>
            <tr><td>State:</td><td><input type="text" value="<%=rs.getString("state")%>"></td></tr>
            <tr><td>City</td><td><input type="text" value="<%=rs.getString("city")%>"></td></tr>
            <tr><td>Telephone No:</td><td><input type="text" value="<%=rs.getInt("telephone")%>"></td></tr>
            <tr><td>Mobile:</td><td><input type="text" value="<%=rs.getInt("mobile")%>"></td></tr>
           </table>
           <%
           }
          else{
           response.sendRedirect("login.jsp");
          }
        }
    catch(Exception e){
    System.out.println(e);
}
%>

June 5, 2012 at 12:36 PM

continue..

3)register.jsp:

<html>
<form method="post" action="insert.jsp">
<table>
<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>User Name:</td><td><input type="text" name="uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td>Confirm Password:</td><td><input type="password" name="cpass"></td></tr>
<tr><td>Date Of Birth</td><td><input type="text" name="dob"></td></tr>
<tr><td>Age:</td><td><input type="text" name="age"></td></tr>
<tr><td>Email</td><td><input type="text" name="email"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Country</td><td><input type="text" name="country"></td></tr>
<tr><td>State:</td><td><input type="text" name="state"></td></tr>
<tr><td>City</td><td><input type="text" name="city"></td></tr>
<tr><td>Telephone No:</td><td><input type="text" name="tno"></td></tr>
<tr><td>Mobile:</td><td><input type="text" name="mobile"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

4)insert.jsp:

<%@page import="java.sql.*,java.util.*"%>
<%
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String uname=request.getParameter("uname");
String pass=request.getParameter("pass");
String cpass=request.getParameter("cpass");
String dob=request.getParameter("dob");
int age=Integer.parseInt(request.getParameter("age"));
String email=request.getParameter("email");
String address=request.getParameter("address");
String country=request.getParameter("country");
String state=request.getParameter("state");
String city=request.getParameter("city");
int telephone=Integer.parseInt(request.getParameter("tno"));
int mobile=Integer.parseInt(request.getParameter("mobile"));
        try{
         Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into register(firstname,lastname,username,password,confirm_pass,dob,age,email,address,country,state,city,telephone,mobile) values('"+fname+"','"+lname+"','"+uname+"','"+pass+"','"+cpass+"','"+dob+"',"+age+",'"+email+"','"+address+"','"+country+"','"+state+"','"+city+"',"+telephone+","+mobile+")");
        out.println("Data is successfully inserted!");
        response.sendRedirect("login.jsp");
        }
        catch(Exception e){
        System.out.print(e);
        e.printStackTrace();
        }
        %>









Related Tutorials/Questions & Answers:
JSP data after login where different users data are stored in database
JSP data after login where different users data are stored in database  hey..i have a login page where different users first registered... where different users data are stored in database,plz...provide me answer its
the last data entered into database is getting stored again after refreshing
the last data entered into database is getting stored again after refreshing  hey all i made a shout box using php and mysql but the last data... if the data is deleted from the database the last data entered is getting posted plz help
Advertisements
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ... the user information.. now their is a login and registration page for newuser. after the user has filled the form he should go to the welcome page where he
Retriving data stored in database
Retriving data stored in database  Hi, How to retrive data from my sql database using Hibernate,Spring and tapestry please give me an example.I am new to this Hibernate and Spring
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  sir am doing project in ASP.NET useful for my college that is placement portal...please help in display details of particular student after he login ...i want
where are program instructions and data values stored
where are program instructions and data values stored  Where are program instructions and data values stored in Computer?   In Storage. Actually, whichever program and data we use in our computers are stored in Storage
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i... procedure for inserting data into oracle database as bind variable and same
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where... help me. ALL DATABASE CONNECTIONS ARE OK. THE ERROR IS SHOWN IN "WHERE". IT SAYS
login data
the data after login i want to show particular data for particular user means if i login i wanna see only myn data how shud i do thanxx in advance...login data   Hiiii Sir I am doing banking project on Asp.net i have
login data
the data after login i want to show particular data for particular user means if i login i wanna see only myn data how shud i do thanxx in advance...login data  Hiiii Sir I am doing banking project on Asp.net i have
how to create alert message after data submitted into database
how to create alert message after data submitted into database  I want to create alert message box after data stored into database and redirect to another page, how to do
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
How to Restore The Lossed data in MYSQL database after the System is formatted
How to Restore The Lossed data in MYSQL database after the System is formatted  How to Restore The Lossed data in MYSQL database after the System is formatted
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
automatically move next page when data fetched from database is stored in text field
automatically move next page when data fetched from database is stored in text field  hi I have php page where i have two text fields . The data are stored in database wherein when the in the first text field the data is already
auto suggest where the data should come from database - Ajax
auto suggest where the data should come from database  auto suggest in (java script or ajax)where the data should come from one of the table in database thnks in advance MamthaDatta  Hi Friend, You can visit
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
how to disable submit button after login in jsp
to disable submit button after login in jsp? Thanks   Hi, You can...how to disable submit button after login in jsp  Hi, I have... achieve it. Check more tutorials: Setting and Getting Data in jsp through
to read data stored in ArrayList - Struts
to read data stored in ArrayList  this is regarding struts2, i have create one ArrayList object and in that i have stored 4 User class objects taking them from database. Now i want to read the data of all 4 User objects from jsp
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
in a textbox. The data is stored in database.  The code for retrieving data from database into Drop Down List. <% DataSource data = new... for displaying quantity is below but its now working.I am new to jsp, so dont know how
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <..."; if(sdto.getPid()==null || !sdto.getPid().equals("")) { query=query+" "+"where pid...="false"%> The following details are stored in DB {pid} {pname} {price
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 oracle10G database already contain table name admin which has name, password
Fastest way to upload huge raw data in database - c#, Java or stored procedure
Fastest way to upload huge raw data in database - c#, Java or stored procedure  I have huge raw data that needs to uploaded in database... this data - Stored procedures, Java or c#. Why? What are the advantages
displaying data retrieved from a database in a jsp page
displaying data retrieved from a database in a jsp page  the page should display username, emailid, telephone in addition to tthe tagline however... sql = "select billid, customerid, billdate, status from customerbills where
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database...+","+ph2+")"); out.println("Data is successfully inserted
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named...;/head> <body> <h2>Data from the table 'stu_info' of database... dirctory of welcome_to_database_query.jsp. Click on the link given in the first jsp
jobs after data analytics
jobs after data analytics  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: jobs after... learn the topic "jobs after data analytics". Also tell me which
how to get data from database into dropdownlist in jsp
tutorial go through the link JSP Get Data Into Dropdown list From Database   ...how to get data from database into dropdownlist in jsp  Can anybody... the database and set it into dropdown list in jsp please help <br/>
Inserting data on a database in servlet - JSP-Servlet
Inserting data on a database in servlet  Hi I am following... to a databse by a servlet.I used the example in "Inserting Data In Database table... of a table,that is none of the data which i tried to enter into database by using
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... table's data I have created a JSP page where written the Java code
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them
design chart takes data from database and through jsp page
design chart takes data from database and through jsp page  how can I design chart takes data from database and through in jsp page
how to store the data in a array retrived from the database - JSP-Servlet
of an employee in a row which is entered at different times which is stored in database,and i need to disply all the employees record in a single jsp. pls can any...how to store the data in a array retrived from the database  hi
data retrival from database throw simple jsp..
data retrival from database throw simple jsp..  We can retrieve the the data from data base simple jsp page: Jsp Page:retrive.jsp <% Connection conn = null; ResultSet rs = null
Insert Data in Table Using Stored Procedure
data into a table using stored procedure. Steps: 1.Create database... Insert Data in Table Using Stored Procedure ... is the video tutorial of Creating and calling the Stored Procedure in MySQL Database
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my...:8080/examples/jsp/1/insert.jsp"> <table> <tr><td>
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... and database name. Here machine name id localhost and database name... = null; // declare a resultset that uses as a table for output data from
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  //Customer Name: <select name="name"> <% try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost
Spring Security customized login from database
Spring Security customized login from database In this section, you will learn how to secure URL access using customized login where password stored in database table. EXAMPLE In the below example, we have created a customized login
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Customer Name:<select name="name"> <% try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc
Data needs to be gathered in XML file from the database (MySql) using JSP
Data needs to be gathered in XML file from the database (MySql) using JSP ... data regarding particular id from the database table. Data needs to be gathered in XML file from the database (MySql) using appropriate JSP/Java Bean functions
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put in front of a featched data and when i clicked on this button then the data
insert data into database
the data into the jsp page that data stored into the database.Here the error...insert data into database  hi,thanks for reply just i am doing student information project,frontend is jsp-servlet and backend is msaccess2007. i

Ads