Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


preeti
login-password
2 Answer(s)      6 years and 4 months ago
Posted in : Java Beginners



Advertisement
View Answers

September 13, 2008 at 10:59 AM


Hi friend,

<html>
<title>login application in jsp</title>
<head>

<script type="text/javascript">

function validateForm(theForm){



if(theForm.userid.value==""){

//Please enter username

alert("Please enter User Name.");

theForm.userid.focus();

return false;

}
if(theForm.password.value==""){
//please enter passward
alert("Please enter Password.");
theForm.password.focus();
return false;
}

return true;
}
</script>
</head>

<body>
<br>
<br/>
<center>

<table border="1" width="400px" bgcolor="pink" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="POST" action="loginAction.jsp" onsubmit="return validateForm(this);">

<h2 align="center"><font color="red">Login Application in JSP</font></h2>
<table border="0" width="350px" cellspacing="2" cellpadding="4">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="20"/> </td>
</tr>

</table>
<center>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>
</center>
</form>
</td>
</tr>
</table>
</center>
</body>

</html>


September 13, 2008 at 11:02 AM


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


<%



String userid = request.getParameter("userid");

String password = request.getParameter("password");



Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";

try {

Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,pass);

Statement st = con.createStatement();

String strQuery = "select * from login where userid='"+userid+"' and password='"+password+"'";

out.println(strQuery);

ResultSet rs = st.executeQuery(strQuery);



while(rs.next()){

if((rs.getString(1).equals("admin")) && (rs.getString(2).equals("admin")))

{

session.setAttribute("userid",userid);

response.sendRedirect("userForm.jsp");
}


if((rs.getString(1).equals("user")) && (rs.getString(2).equals("user")))

{

session.setAttribute("userid",userid);

response.sendRedirect("registrationForm.jsp");
}

else{

response.sendRedirect("loginForm.jsp");

}


}

System.out.println("Connected to the database");

con.close();



} catch (Exception e) {

e.printStackTrace();

}

%>

------------------------------------------------

Visit for more information.

http://www.roseindia.net/jsp/bank.shtml

Thanks & Regards

Amardeep


Related Tutorials/Questions & Answers:
login-password - Java Beginners
login-password  complete code of login-password form then how to connect the bank simulation project?   Hi friend, login...; } if(theForm.password.value==""){ //please enter passward alert("Please enter Password
Login Password Validation iPhone / iPAD
Login Password Validation iPhone / iPAD  HOW TO WRITE A TEST CASE TO SET THE VALIDATION FOR LOGIN AND PASSWORD FIELD IN OBJECTIVE C, IOS.   @implementation LoginViewTests - (void)testPasswordFieldIsNotEmpty
Advertisements
PHP User Authentication Login and password check Tutorial
to the database. $dbname="name"; #Password to verify its you. $dbpass="
password check
password check  how to check sighup passowrd and login password
java - Java Beginners
java  hi, I need the coding for encoding the login password using MD5 algorithm. please help me as soon as possible. Regards, Valarmathi
HQL Query in execute method of Struts2
HQL Query in execute method of Struts2  I am making login page in struts2 and using hibernate . Now I wants to pull user name and password from database and match the login password given by user. But I am not able to fetch
SQL and JSP
SQL and JSP  1.sql database 1.store login and password details along with user name 2.list of employees with all relevant personal details... and password entry box.the user id and password entered will be evaluated
Spring Login Page Error
Spring Login Page Error  Dear Sir/Madam, I used the spring login page code. The index page is working fine. When i try to entry login and password , i am getting the below error: Please help me out in this. Let me know if i
Email sending in jsp - JSP-Servlet
Login Password Back-end coding: EmailServlet.java... = request.getParameter("login"); String password = request.getParameter("password..."); Authenticator auth = new SMTPAuthenticator(login, password
sessions management
sessions management  I have a problem with the session management of my applcation deployed in tomcat. in fact, my application allows only one session to a login / password given. I then add in the database a flag for each user
Java swing
=st.executeQuery("select * from login where username='"+value1+"' and password...(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE...Java swing  how to create the login form?   1
login
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR... java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form
Beneficiaries Organizations
will provide a login and password to your students at no cost. Experience certificate... institutions can also be benefited by login us. The bright student will highlight
Swings - Java Beginners
Swings  iam created one login form.iam using mysql database.values also stored in database.after login how to go to another page  Hi Friend...); label2 = new JLabel(); label2.setText("Password:"); text2 = new
login screen - Java Beginners
* FROM login where username='"+value1+"' and password='"+value2... login or password","Error",JOptionPane.ERROR_MESSAGE); text1.setText...login screen  how can code a login screen please send me the code
j2me - Java Beginners
the sensitive information. The information is protected by login and password, which can
j2me project guide - Java Beginners
the sensitive information. The information is protected by login and password
java project - Java Beginners
. The information is protected by login and password, which can be assigned to each single user
java code - Java Beginners
"); } else{ JOptionPane.showMessageDialog(null,"Incorrect login or password... in swing and i want whn we click on start my login page is come next how we... e){ LoginDemo login=new LoginDemo(); login.setVisible(true); login.pack
Create Project SplashScreen - Java Beginners
login where username='"+value1+"' && password='"+value2+"'"); while... that visible only for 1 minute after 1 minute i want to display LogIn form how i...(); window.getContentPane().add(new JLabel("Loading Login Page
Log In Form Validations - Java Beginners
)) { JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...)password if two Jtextfields are blanks i want to show msg blank Username and Password , How I can Do That ,plz Help Me Sir.  Hi Friend, Try
login form
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR...login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components
login form
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components
nextpage
page display. In case if user enters incorrect username or password then login...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...nextpage  my login form using java awt-swing ..still appearing after
RichFaces: Login & Registration Application:
in front of the user. User fills the login and password information and enters... is not able to login to the application i.e. forget the password, it can get password by clicking the link "Forgot Password?" in the login page itself
Login Form in Java - Java Beginners
= st.executeQuery("SELECT * FROM login where username='"+value1+"' && password='"+value2...Login Form in Java  Hi, In my Project, I am using Java-JDBC-Mysql. Idea is as below. when user give user-id & password, on that he can get
Servlet-JSP population - JSP-Servlet
to validate the login and password. I have got all this right. once he gets logged...Servlet-JSP population  Hi I have a login page which accepts... and password is working fine. my table cartlist has rows in it.I checked
abt java - Java Beginners
{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error... authetication ... in this code it take user name password and a user certificate(which... the Login Code in swings. import javax.swing.*; import java.awt.*; import
abt proj - Java Beginners
("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("Login... = st.executeQuery("SELECT * FROM login where username='"+value1+"' && password...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR
java - Java Beginners
and password matches then login and put registry details or say invalid input. i...("Password:"); text2 = new JPasswordField(15); SUBMIT=new JButton("Login...{ JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE
java date - Java Beginners
,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE); text1.setText...); text1.setBounds(500,50,100,20); label2 = new JLabel(); label2.setText("Password...(500,80,100,20); SUBMIT=new JButton("Login"); SUBMIT.setBounds(500,110,100,20
Advertisements
 

 

 

DMCA.com