View Answers

September 13, 2008 at 10:59 AM

Hi friend,

<title>login application in jsp</title>

<script type="text/javascript">

function validateForm(theForm){


//Please enter username

alert("Please enter User Name.");


return false;

//please enter passward
alert("Please enter Password.");
return false;

return true;


<table border="1" width="400px" bgcolor="pink" cellspacing="0" cellpadding="0">
<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">
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="20"/> </td>

<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>


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://";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";

try {

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

Statement st = con.createStatement();

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


ResultSet rs = st.executeQuery(strQuery);


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




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








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


} catch (Exception e) {





Visit for more information.


Thanks & Regards



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
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
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
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
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
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
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
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
java project - Java Beginners
. The information is protected by login and password, which can be assigned to each single user
j2me project guide - Java Beginners
the sensitive information. The information is protected by login and password
j2me - Java Beginners
the sensitive information. The information is protected by login and password, which can
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
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
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
{ 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
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
java - Java Beginners
(pass1)) { JOptionPane.showMessageDialog(null,"Incorrect login or password","Error...java  hi iam created a desktop login form using swings , and it works properly and my doubt is when valid user is login , the user name ,server
java - Java Beginners
login or password","Error",JOptionPane.ERROR_MESSAGE); text1.setText...(500,50,100,20); label2 = new JLabel(); label2.setText("Password...(500,80,100,20); SUBMIT=new JButton("Login"); SUBMIT.setBounds(500,110,100,20
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
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
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
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
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
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
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
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