jsp login code ... when username , drop down box and password is correct

jsp login code ... when username , drop down box and password is correct

i need a jsp code for login.... when username password and dropdown box value is correct.... the drop down box values should be retrieved from database..... please provede me codes for that..... thnk u

View Answers

April 4, 2012 at 3:25 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>Select Company: </td><td>
<select name="com">
<%
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");
           while(rs.next()){
           %>

<option value="<%=rs.getString("company")%>"><%=rs.getString("company")%></option>
<%
           }
%>
</select>
</td></tr>
<tr><td></td><td><input type="submit" value="Login"></td></tr>
</table>
</form>
</html>

2)check.jsp:

<%@page import="java.sql.*"%>
<%
try{
String user=request.getParameter("user");
String pass=request.getParameter("pass");
String com=request.getParameter("com");
 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+"'and company='"+com+"'");
           int count=0;
           while(rs.next()){
           count++;
          }
          if(count>0){
           out.println("welcome "+user);
           }
          else{
           response.sendRedirect("login.jsp");
          }
        }
    catch(Exception e){
    System.out.println(e);
}
%>

April 5, 2012 at 7:03 PM

thank u... the half..i.e the first program works.... the value is retrieved from database into combo box..... but the validation is not happening..... the all three username , passwrod and company name are corect but its showing as wrong..... i dont know how to check the combo box selected value.... pls help me.... thnx









Related Tutorials/Questions & Answers:
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box value is correct.... the drop down box values should be retrieved from database
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct... in dropdown box.... so when i login i all the three username,password and dropdown box........ but in the drop down box ... i need to get the values from backend
Advertisements
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct... in dropdown box.... so when i login i all the three username,password and dropdown box...=document.form.user.value; var password=document.form.pass.value; if(username==""){ alert("Enter
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me... login where username='"+user+"' and password='"+pass+"'and company='"+com
drop down box - JSP-Servlet
drop down box  when i enter some letter in the input box,the corresponding words of that particular letter must be displayed below as a list from the data base in the same input box as drop down. Thanks&Regards, VijayaBabu.M
Login With Drop Down
Login With Drop Down   Hi all, I am doing a project using JSP. My... box and then login to the page. I have a drop down list box with Customs... by selecting the drop down box. Suppose the Customs username is 1001 and Accounts
Login With Drop Down, Having Departments in different table
is to select the department from the drop down box and then login to the page. I have a drop down list box with Customs and Accounts..A Username and a Password field.Now want to login to the page by selecting the drop down box. Suppose
dependent drop down box - JSP-Servlet
dependent drop down box  haloo sir Please give me the solution how to extract data from dependent drop down box with page refresh... saroj  Hi Friend, Try the following code
How to Display Username After Login in JSP
How to Display Username After Login in JSP In this section we will discuss how to display the Username and password after the successful login. In JSP... page in which username and password is created. So, when you submit the details
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Drop Down Box
Drop Down Box  In a Drop Down box I want to show the user All the Country In the World. And when he type A-z,then each of the type Show those country which start with those word. Like I For-India
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
sir plz help in design a jsp page whichis as follow username [_____] select [__>]password [_____] after selection then onlypassword text box is visible
sir plz help in design a jsp page   sir plz help in design a jsp page which is as follow username [ _ ] select [ > ] password [ _ ] after selection then only password text box is visible
dynamic drop down list box - Java Beginners
dynamic drop down list box  hi all , I want to dynamically populate a drop down box from an sql query in a servlet program, using only html... = "com.mysql.jdbc.Driver"; String userName ="amar"; String password
Pls provide me jsp code to get values in drop down list from another table's field....
Pls provide me jsp code to get values in drop down list from another table's... in customer registration page and should be shown in drop down box in front end... pages..... when i insert data in company registration .. it ll have company id
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
validating username and password in servlet and redirect to login page with error message if not valid
validating username and password in servlet and redirect to login page with error message if not valid  hi i want to validate my login page username... error message saying "Invalid username and password" in my login page. please help
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
JSP code for forget password
JSP code for forget password  I need forget password JSP code.. example http://www.roseindia.net/users/forgotpassword.html
jsp drop down without refresh - JSP-Servlet
jsp drop down without refresh  Sir I have tried two depenedent jsp dropdown in jsp page,But the probleam is when i select first drop down its... jsp same probleam also arise. Please tell me how to use the drop down without
forgot password code in jsp
forgot password code in jsp  forgot password code in jsp   Please visit the following link: http://www.roseindia.net/jsf/richfaces
JSP Dependent Drop Down Menu
JSP Dependent Drop Down Menu  Hey Guy/Gals! I need someone help to guide me in creating a drop down menu, where the first menu affects the second...; The given code will help you to create a dependent dropdown box. 1
Username password
=st.executeQuery("select * from login where username='"+value1+"' and password='"+value2... with the validation, so that if the username and password match it will continue... that checks whether the username and password is valid or not. If the user
how to check username & password from database using jsp
how to check username & password from database using jsp  Hello, I have created 1 html page which contain username, password & submit button.... name is amit and password is ddave. so hw could i check whether the username
HTML Login Page Code
the person enters the correct username and password, it will not Login. Once you enter the correct Username and Password, you will be redirected to another page... JavaScript validation in Login page. We have set username and password value
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated...) in database and try the following code:ADS_TO_REPLACE_1 <%@page import="java.sql.... Friend, If you want the code in ajax then try the following code:ADS
how to import values from database to the drop down box
employee page i kept a drop down box for employee Ids i want all employee IDs will display in the drop down box please help me with the code...how to import values from database to the drop down box   hi iam
display table details when selecting table name in drop down liat
display table details when selecting table name in drop down liat  Hello, Am having problem in my project... i want to retrive the data from mysql database to the dropdownlist in jsp. Example: 1st i want to display the list
login-password - Java Beginners
login-password  complete code of login-password form then how to connect the bank simulation project?   Hi friend, login...; } Login Application in JSP
DropDown Department Login
me the code on how to login using the drop down box and the Username... down box and then login to the page. I have a drop down list box with Customs... by selecting the drop down box. Suppose the Customs username is 1001 and Accounts
username and password in servlet
username and password in servlet  i'm usng eclipse luna(java programming) Sevlet and apache tomcat8.0 i need to do a login page then after login it must display either invalid user or valid user here is what i done for login
to access value of drop down value in beans when dropdown is populated using ajax
to access value of drop down value in beans when dropdown is populated using ajax  i want to access value of dropdown box in beans .. and this drop down was filled using ajax. plz help
Drop-down text selection in jsp/html
Drop-down text selection in jsp/html  Hi, I am trying to create JSP page where I have two drop-downs. There are two-sets of data - First set.... Now the first dropdown will have all the values. The second drop-down depends upon
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list, this is my code, <div id="age"> Age <select name='NEW'> <option
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list, this is my code, <div id="age"> Age <select name='NEW'> <option
to update drop down list value when selected from website
to update drop down list value when selected from website  hi help me, i want to insert value into db when i select from a drop down list, this is my code, <div id="age"> Age <select name='NEW'> <option
code to validate username password of gmail and procedures to establish jdbc connectivity to store unread mails and retreive it..
, 1)I am in need of code to establish username and password of gmail 2)code in jsp to validate the username and password of my gmail mentioned above...code to validate username password of gmail and procedures to establish jdbc
code to validate username password of gmail and procedures to establish jdbc connectivity to store unread mails and retreive it..
, 1)I am in need of code to establish username and password of gmail 2)code in jsp to validate the username and password of my gmail mentioned above...code to validate username password of gmail and procedures to establish jdbc
code to validate username password of gmail and procedures to establish jdbc connectivity to store unread mails and retreive it..
, 1)I am in need of code to establish username and password of gmail 2)code in jsp to validate the username and password of my gmail mentioned above...code to validate username password of gmail and procedures to establish jdbc
code to validate username password of gmail and procedures to establish jdbc connectivity to store unread mails and retreive it..
, 1)I am in need of code to establish username and password of gmail 2)code in jsp to validate the username and password of my gmail mentioned above...code to validate username password of gmail and procedures to establish jdbc
code to validate username password of gmail and procedures to establish jdbc connectivity to store unread mails and retreive it..
, 1)I am in need of code to establish username and password of gmail 2)code in jsp to validate the username and password of my gmail mentioned above...code to validate username password of gmail and procedures to establish jdbc
login in jsp
login in jsp  i need code for login which is verify the registeration form username and password field,if it correct user enter the next and otherwise show the failed message.   JSP Login Form 1)login.jsp: <html>
Change Password Code in JSP
Change Password Code in JSP In this example we will see how to change password code in jsp. First of all we have created a form where we have displayed...;/head> <h2 align="center"><strong>Change password in JSP
validating username and password from database
validating username and password from database  Hello sir, i am developing a login page. i want that when i fill data in text fields. it validate data from database. if enter data is match from database. page goes to next page
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
Get values in drop down list
Get values in drop down list  Pls provide me jsp code to get values in drop down list from another table's field. my project has customer... in drop down box in front end..... pls provide me code.. thanx
displaying section in the jsp based on the sected value in drop down - Java Beginners
displaying section in the jsp based on the sected value in drop down   Hi friend, i have one problem in my jsp. i.e i have to display section on the jsp based on the selected value in the drop down list using java script code
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc...); } } } **HTML code of it:-** <html xmlns:wicket="..."> <

Ads