Home Answers Viewqa JSP-Servlet jsp login code ... when username , drop down box and password is correct

 
 


Abinesh
jsp login code ... when username , drop down box and password is correct
2 Answer(s)      a year and a month ago
Posted in : JSP-Servlet

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 Pages:
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
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
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
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
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
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
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
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
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
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
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
dynamic drop down
into the designation drop down (use jsp+javascript+servlet) reply soon   1...dynamic drop down   I have created 2 drop downs in jsp.1..., the page should refresh quickly but keep all the correct info and then depending
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
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
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
Login Authentication in JSP
from database This example will describe you the use of Select Box in a JSP... object  to dispatch it to the JSP page's select box. Following lines of code is written to send data to JSP page by setting attribute 
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
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>
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
dynamic drop down list
dynamic drop down list  I want to create 2 drop down list, where it takes value from database and the two list are dependent..means if I select... on the value chosen from the previous. want code in javascript and jsp, Can you help
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="..."> <
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="..."> <
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="..."> <
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="..."> <
login
want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code
login
want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code
login
want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code
login
want the code for login.. i created design it contains the field of user name and password and the submit button.. when i click the submit button it has to check the user name and password from the data base.. please help me for the code
to enter into a particular page only if the username,password and listbox value mtches
) matches using "jsp".where the username,password,user type are stored in a single table... with username, password text box and only for the the first record(user details...to enter into a particular page only if the username,password and listbox value
login
login  how to create login page in jsp   Here is a jsp code that creates the login page and check whether the user is valid or not. 1... where username='"+user+"' and password='"+pass+"'"); int count=0
Ajax drop down and textbox
Ajax drop down and textbox  hie frnds I have a dropdown menu in the 3 options(1,2,3) are there if i choose 1 then I should get 1 text box if i select... menu consisting of options 1,2,3. When the user select any option from
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
Dependent drop down list
Dependent drop down list  hi,i am trying to design a form on which 2 dependent drop down list is used my code is successful but when i select class... in fields before drop down list get blank.what can i do for this? This is the code
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
jsp drop down-- select Option
jsp drop down-- select Option  how to get drop down populated...) in database and try the following code: <%@page import="java.sql.*"%> <html>... want the code in ajax then try the following code: 1)country.jsp: <%@page
Fetch logged in username in Spring Security
;document.f.j_username.focus();'> <h3>Login with Username and Password (Custom...=Wrong username\ /\ password login.jsp <%@ taglib prefix="c"... credential are correct, following page will appear : When you logoff
Drop down and radio button value on edit action
Drop down and radio button value on edit action  HI, I have a title field and a payment type field for title i have used drop down with values...; by cheque When 'm adding a new customer it works fine as we have to select
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
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
data should not repeat in the drop down list when it is loading dynamically from database
data should not repeat in the drop down list when it is loading dynamically... the whole department field from the data base (i.e in the drop down list... be included in the drop down list. 1)selDept.jsp: <%@page import
Drop down for search textbox like google search
Drop down for search textbox like google search  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop down list appear, then we can select one of word as our
Dependant & dynamic drop down list
Dependant & dynamic drop down list  I don't know this should be in this or AJAX forum. I have one dynamic drop down list from data base (working... on the values selected by user in first drop down list. How to achieve this ?   
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
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
data should not repeat in the drop down list when it is loading dynamically from database
data should not repeat in the drop down list when it is loading dynamically... correct this and send me the code. Thank you in advance  1)selDept.jsp... the database but when we give same department name it is repeting i.e if we enter
Select functionality of drop down list - Struts
Select functionality of drop down list  Hi, I have to write a code(in struts application) in which if user select HIDE from the drop down list... have Drop down list having element Test1,Test2,Test3,HIDE and one Text msg box

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.